LayoutDmduskmoonimplemented3 demos

DmLayout

DmLayout combines menus, breadcrumbs, and collapsible navigation in an application shell.

Import@duskmoon-dev/components/dm-layout
2API sections
23documented props
4behavior scenarios
Key API
menusselectedKeyopenAllKeyscollapseddefaultCollapsedhideProductHeader

Usage

When to use

  • Use it in DuskMoon application screens that need a packaged, opinionated workflow component.
  • Reach for the lower-level standard component when the screen needs custom composition.

Implementation notes

StylesheetImport @duskmoon-dev/components/styles.css once in the app or docs shell.
StateStart with default props for static examples, then switch to controlled props when state must be shared.
ThemeThe preview inherits the active DuskMoon data-theme value from the docs layout.

Features

DuskMoon workflow wrapper

Wraps lower-level primitives into a higher-level DuskMoon-prefixed workflow API.

Application defaults

Examples show the defaults and composition points expected by internal DuskMoon app screens.

Primary API surface

DmLayout is most often configured through `menus`, `selectedKey`, `openAllKeys`, `collapsed`.

Covered behavior

Derives selected menu, open keys, breadcrumb, and tips

Feature Demos

Feature demos are authored for the component page, then supplemented with behavior scenarios from the component test coverage.

Preview

Workspace overview

A shared place to organize the team's current work.

Current page: /workspace

Workspace navigation

authored

Select a menu item to update the controlled selectedKey, page content, and derived breadcrumb.

Source
import "@duskmoon-dev/components/styles.css";
import { useState } from "react";
import { DmLayout } from "@duskmoon-dev/components/dm-layout";
import type { DmMenuSchema } from "@duskmoon-dev/components/dm-menu";

const menus: DmMenuSchema[] = [
  {
    "menuName": "Overview",
    "menuUrl": "/workspace",
    "iconStr": "◈"
  },
  {
    "menuName": "Projects",
    "menuUrl": "/workspace/projects",
    "iconStr": "▦"
  },
  {
    "menuName": "Reports",
    "menuUrl": "/workspace/reports",
    "iconStr": "▤"
  }
];
const pages: Record<string, { title: string; description: string }> = {
  "/workspace": {
    "title": "Workspace overview",
    "description": "A shared place to organize the team's current work."
  },
  "/workspace/projects": {
    "title": "Projects",
    "description": "Review active projects and plan the next delivery."
  },
  "/workspace/reports": {
    "title": "Reports",
    "description": "Track progress across the workspace and recent deliveries."
  }
};

export function Example() {
  const [selectedKey, setSelectedKey] = useState("/workspace");
  const page = pages[selectedKey];
  return (
    <div style={{ minWidth: 0 }}>
      <DmLayout
        menus={menus}
        productTitle="Northstar"
        productIcon="◈"
        selectedKey={selectedKey}
        onMenuClick={setSelectedKey}
        onBreadcrumbClick={setSelectedKey}
        style={{ minHeight: 320 }}
      >
        <section aria-label="Workspace page" style={{ minWidth: 0 }}>
          <h3 style={{ margin: 0, fontSize: 20 }}>{page.title}</h3>
          <p style={{ lineHeight: 1.6 }}>{page.description}</p>
          <p style={{ fontSize: 12, overflowWrap: "anywhere" }}>Current page: {selectedKey}</p>
        </section>
      </DmLayout>
    </div>
  );
}
Preview
Active projects are ready for the next team review.

Active projects

Keep upcoming milestones and current assignments in view.

Current page: /projects/active

Nested navigation and tips

authored

Nested selection opens its parent menu and derives breadcrumbs and contextual tips from the menu schema.

Source
import "@duskmoon-dev/components/styles.css";
import { useState } from "react";
import { DmLayout } from "@duskmoon-dev/components/dm-layout";
import type { DmMenuSchema } from "@duskmoon-dev/components/dm-menu";

const menus: DmMenuSchema[] = [
  {
    "menuName": "Projects",
    "menuUrl": "/projects",
    "iconStr": "▦",
    "children": [
      {
        "menuName": "Active projects",
        "menuUrl": "/projects/active",
        "iconStr": "◉",
        "tipsEnabled": true,
        "tips": "Active projects are ready for the next team review."
      },
      {
        "menuName": "Project archive and completed work",
        "menuUrl": "/projects/archive",
        "iconStr": "▤",
        "tipsEnabled": true,
        "tips": "Archived projects stay available for reference."
      }
    ]
  },
  {
    "menuName": "Members",
    "menuUrl": "/members",
    "iconStr": "◎"
  }
];
const pages: Record<string, { title: string; description: string }> = {
  "/projects": {
    "title": "Projects",
    "description": "Choose active projects or browse completed work."
  },
  "/projects/active": {
    "title": "Active projects",
    "description": "Keep upcoming milestones and current assignments in view."
  },
  "/projects/archive": {
    "title": "Project archive",
    "description": "Browse completed work and decisions from earlier deliveries."
  },
  "/members": {
    "title": "Workspace members",
    "description": "Review the people contributing to the workspace."
  }
};

export function Example() {
  const [selectedKey, setSelectedKey] = useState("/projects/active");
  const page = pages[selectedKey];
  return (
    <div style={{ minWidth: 0 }}>
      <DmLayout
        menus={menus}
        productTitle="Northstar"
        productIcon="◈"
        selectedKey={selectedKey}
        onMenuClick={setSelectedKey}
        onBreadcrumbClick={setSelectedKey}
        style={{ minHeight: 320 }}
      >
        <section aria-label="Workspace page" style={{ minWidth: 0 }}>
          <h3 style={{ margin: 0, fontSize: 20 }}>{page.title}</h3>
          <p style={{ lineHeight: 1.6 }}>{page.description}</p>
          <p style={{ fontSize: 12, overflowWrap: "anywhere" }}>Current page: {selectedKey}</p>
        </section>
      </DmLayout>
    </div>
  );
}
Preview

Sidebar expanded

Projects

Review active projects and plan the next delivery.

Current page: /workspace/projects

Controlled sidebar collapse

authored

Share collapsed state between the external toggle and onCollapse. Selection and content remain intact when the sidebar changes width.

Source
import "@duskmoon-dev/components/styles.css";
import { useState } from "react";
import { DmLayout } from "@duskmoon-dev/components/dm-layout";
import type { DmMenuSchema } from "@duskmoon-dev/components/dm-menu";

const menus: DmMenuSchema[] = [
  {
    "menuName": "Overview",
    "menuUrl": "/workspace",
    "iconStr": "◈"
  },
  {
    "menuName": "Projects",
    "menuUrl": "/workspace/projects",
    "iconStr": "▦"
  },
  {
    "menuName": "Reports",
    "menuUrl": "/workspace/reports",
    "iconStr": "▤"
  }
];
const pages: Record<string, { title: string; description: string }> = {
  "/workspace": {
    "title": "Workspace overview",
    "description": "A shared place to organize the team's current work."
  },
  "/workspace/projects": {
    "title": "Projects",
    "description": "Review active projects and plan the next delivery."
  },
  "/workspace/reports": {
    "title": "Reports",
    "description": "Track progress across the workspace and recent deliveries."
  }
};

export function Example() {
  const [selectedKey, setSelectedKey] = useState("/workspace/projects");
  const [collapsed, setCollapsed] = useState(false);
  const page = pages[selectedKey];
  return (
    <div style={{ minWidth: 0 }}>
      <button type="button" className="btn btn-outline" onClick={() => setCollapsed(!collapsed)}>
        {collapsed ? "Expand sidebar" : "Collapse sidebar"}
      </button>
      <p role="status">Sidebar {collapsed ? "collapsed" : "expanded"}</p>
      <DmLayout
        menus={menus}
        productTitle="Northstar"
        productIcon="◈"
        selectedKey={selectedKey}
        onMenuClick={setSelectedKey}
        onBreadcrumbClick={setSelectedKey}
        collapsed={collapsed}
        onCollapse={setCollapsed}
        style={{ minHeight: 320 }}
      >
        <section aria-label="Workspace page" style={{ minWidth: 0 }}>
          <h3 style={{ margin: 0, fontSize: 20 }}>{page.title}</h3>
          <p style={{ lineHeight: 1.6 }}>{page.description}</p>
          <p style={{ fontSize: 12, overflowWrap: "anywhere" }}>Current page: {selectedKey}</p>
        </section>
      </DmLayout>
    </div>
  );
}

API

The API reference below lists every parsed exported type or interface for DmLayout. Start with `menus`, `selectedKey`, `openAllKeys`, `collapsed` for common usage.

Types: packages/components/src/components/dm-layout/DmLayout.types.tsScenarios: packages/components/src/components/dm-layout/DmLayout.test.tsx
DmLayoutPropsinterface extends Omit<ComponentProps<"div">, "onSelect">, Omit<LayoutProps, "children">
PropTypeRequiredDescription
menusDmMenuSchema[]Nomenus configures DmLayout.
selectedKeystringNoselectedKey configures DmLayout.
openAllKeysbooleanNoopenAllKeys configures DmLayout.
collapsedbooleanNocollapsed configures DmLayout.
defaultCollapsedbooleanNodefaultCollapsed configures DmLayout.
hideProductHeaderbooleanNohideProductHeader configures DmLayout.
productIconReactNodeNoproductIcon configures DmLayout.
productTitleReactNodeNoproductTitle configures DmLayout.
breadcrumbItemsDmBreadcrumbItem[]NobreadcrumbItems configures DmLayout.
aheadBreadcrumbItemsDmBreadcrumbItem[]NoaheadBreadcrumbItems configures DmLayout.
behindBreadcrumbItemsDmBreadcrumbItem[]NobehindBreadcrumbItems configures DmLayout.
tipsReactNodeNotips configures DmLayout.
localestringNolocale configures DmLayout.
menuPropsOmit<NomenuProps configures DmLayout.
onCollapse(collapsed: boolean) => voidNoonCollapse configures DmLayout.
onMenuClick(key: string, menu?: DmMenuSchema) => voidNoonMenuClick configures DmLayout.
onBreadcrumbClick(url: string) => voidNoonBreadcrumbClick configures DmLayout.
childrenReactNodeNochildren configures DmLayout.
DmLayoutSelectioninterface
PropTypeRequiredDescription
selectedMenuKeystringYesselectedMenuKey configures DmLayout.
selectedBreadcrumbKeystringYesselectedBreadcrumbKey configures DmLayout.
openKeysstring[]YesopenKeys configures DmLayout.
breadcrumbItemsDmBreadcrumbItem[]YesbreadcrumbItems configures DmLayout.
tipsReactNodeNotips configures DmLayout.