DmLayout
DmLayout combines menus, breadcrumbs, and collapsible navigation in an application shell.
@duskmoon-dev/components/dm-layoutUsage
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
Features
Wraps lower-level primitives into a higher-level DuskMoon-prefixed workflow API.
Examples show the defaults and composition points expected by internal DuskMoon app screens.
DmLayout is most often configured through `menus`, `selectedKey`, `openAllKeys`, `collapsed`.
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.
Workspace overview
A shared place to organize the team's current work.
Current page: /workspace
Workspace navigation
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>
);
}Active projects
Keep upcoming milestones and current assignments in view.
Current page: /projects/active
Nested navigation and tips
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>
);
}Sidebar expanded
Projects
Review active projects and plan the next delivery.
Current page: /workspace/projects
Controlled sidebar collapse
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.
packages/components/src/components/dm-layout/DmLayout.types.tsScenarios: packages/components/src/components/dm-layout/DmLayout.test.tsx| Prop | Type | Required | Description |
|---|---|---|---|
menus | DmMenuSchema[] | No | menus configures DmLayout. |
selectedKey | string | No | selectedKey configures DmLayout. |
openAllKeys | boolean | No | openAllKeys configures DmLayout. |
collapsed | boolean | No | collapsed configures DmLayout. |
defaultCollapsed | boolean | No | defaultCollapsed configures DmLayout. |
hideProductHeader | boolean | No | hideProductHeader configures DmLayout. |
productIcon | ReactNode | No | productIcon configures DmLayout. |
productTitle | ReactNode | No | productTitle configures DmLayout. |
breadcrumbItems | DmBreadcrumbItem[] | No | breadcrumbItems configures DmLayout. |
aheadBreadcrumbItems | DmBreadcrumbItem[] | No | aheadBreadcrumbItems configures DmLayout. |
behindBreadcrumbItems | DmBreadcrumbItem[] | No | behindBreadcrumbItems configures DmLayout. |
tips | ReactNode | No | tips configures DmLayout. |
locale | string | No | locale configures DmLayout. |
menuProps | Omit< | No | menuProps configures DmLayout. |
onCollapse | (collapsed: boolean) => void | No | onCollapse configures DmLayout. |
onMenuClick | (key: string, menu?: DmMenuSchema) => void | No | onMenuClick configures DmLayout. |
onBreadcrumbClick | (url: string) => void | No | onBreadcrumbClick configures DmLayout. |
children | ReactNode | No | children configures DmLayout. |
| Prop | Type | Required | Description |
|---|---|---|---|
selectedMenuKey | string | Yes | selectedMenuKey configures DmLayout. |
selectedBreadcrumbKey | string | Yes | selectedBreadcrumbKey configures DmLayout. |
openKeys | string[] | Yes | openKeys configures DmLayout. |
breadcrumbItems | DmBreadcrumbItem[] | Yes | breadcrumbItems configures DmLayout. |
tips | ReactNode | No | tips configures DmLayout. |