Component reference
DashboardLayout
A composed workspace with sidebar, navbar, content and an optional right rail.
Preview
Live previewOptional six-digit hex. Clear to restore the preset. Check contrast with your brand color.
Changes apply to this preview only.
Width adapts to the available space
"use client";
import { useState } from "react";
import {
Avatar,
Card,
CardContent,
DashboardLayout,
Navbar,
NavbarActions,
NavbarBrand,
Sidebar,
SidebarContent,
SidebarHeader,
SidebarItem,
Stat
} from "@pimolu/react";
export function DashboardLayoutExample() {
const [active, setActive] = useState("Overview");
return (
<DashboardLayout
sidebarWidth="13rem"
sidebar={<Sidebar
collapsible
collapseOnMobile={false}
>
<SidebarHeader>Orbit</SidebarHeader>
<SidebarContent
aria-label="Dashboard sections"
>
{
[
"Overview",
"Projects"
].map((label) => <SidebarItem
key={label}
href="#dashboard-content"
active={active === label}
icon={<span
aria-hidden="true"
>◇</span>}
onClick={(event) => { event.preventDefault(); setActive(label); }}
>
{
label
}
</SidebarItem>)
}
</SidebarContent>
</Sidebar>}
navbar={<Navbar>
<NavbarBrand href="#dashboard-content">Your workspace</NavbarBrand>
<NavbarActions>
<Avatar
name="Maya Chen"
size="sm"
/>
</NavbarActions>
</Navbar>}
>
<div id="dashboard-content" className="p-5 space-y-5">
<h2 className="text-2xl">{
active
}</h2>
<Card
size="lg"
>
<CardContent>
<Stat
label="Projects taking shape"
value="12"
description="One idea at a time."
/>
</CardContent>
</Card>
<p>
Compose the regions, then let your application own the content.
</p>
</div>
</DashboardLayout>
);
}More examples
Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.
Sidebar and navbar
The sidebar stays visible while the main content scrolls. The right rail is optional and shown in the next example.
With a right rail
At narrow widths, the sidebar collapses and stacks above the content. The right rail remains available below the main region.
Main content only
Both sidebar and aside are optional; the layout collapses to a single main region and the navbar can still be sticky.
Usage
Provide Sidebar and Navbar through their slots. Widths accept CSS lengths or pixel numbers. The sidebar controls its own collapse state; the layout arranges the regions.
Choose DashboardLayout for this opinionated dashboard composition. AppShell is the more general application structure. The preview uses its own document so its main landmark does not nest inside the documentation's main.
API reference
Generated from the public TypeScript declarations. Native HTML attributes are inherited where the component extends them; this reference includes Pimolu props and selected common native attributes.
PimoluDashboardLayoutProps
Type source| Name | Type | Default | Description |
|---|---|---|---|
sidebar | ReactNode | — | Persistent navigation, usually a Sidebar. |
navbar | ReactNode | — | Top bar, usually a Navbar. |
childrenRequired | ReactNode | — | Main dashboard content. |
aside | ReactNode | — | Optional right rail. |
sidebarWidth | Property.Width<string | number> | undefined | 16rem | Width of the sidebar. Defaults to 16rem. |
asideWidth | Property.Width<string | number> | undefined | 20rem | Width of the aside. Defaults to 20rem. |
stickySidebar | boolean | undefined | false | Keep the sidebar visible while the content scrolls. |
stickyNavbar | boolean | undefined | false | Keep the navbar visible while the content scrolls. |
asideLabel | string | undefined | "Aside" | Accessible name of the right rail. Defaults to "Aside". |
defaultValue | string | number | readonly string[] | undefined | — | Standard React/HTML attribute. |
className | string | undefined | — | Standard React/HTML attribute. |
style | CSSProperties | undefined | — | Standard React/HTML attribute. |
aria-label | string | undefined | — | Defines a string value that labels the current element. |
onChange | ChangeEventHandler<HTMLDivElement, Element> | undefined | — | Standard React/HTML attribute. |
onClick | MouseEventHandler<HTMLDivElement> | undefined | — | Standard React/HTML attribute. |
sidebarReactNodeNo default extracted.
Persistent navigation, usually a Sidebar.
navbarReactNodeNo default extracted.
Top bar, usually a Navbar.
childrenRequiredReactNodeNo default extracted.
Main dashboard content.
asideReactNodeNo default extracted.
Optional right rail.
sidebarWidthProperty.Width<string | number> | undefinedDefault: 16rem
Width of the sidebar. Defaults to 16rem.
asideWidthProperty.Width<string | number> | undefinedDefault: 20rem
Width of the aside. Defaults to 20rem.
stickySidebarboolean | undefinedDefault: false
Keep the sidebar visible while the content scrolls.
stickyNavbarboolean | undefinedDefault: false
Keep the navbar visible while the content scrolls.
asideLabelstring | undefinedDefault: "Aside"
Accessible name of the right rail. Defaults to "Aside".
defaultValuestring | number | readonly string[] | undefinedNo default extracted.
Standard React/HTML attribute.
classNamestring | undefinedNo default extracted.
Standard React/HTML attribute.
styleCSSProperties | undefinedNo default extracted.
Standard React/HTML attribute.
aria-labelstring | undefinedNo default extracted.
Defines a string value that labels the current element.
onChangeChangeEventHandler<HTMLDivElement, Element> | undefinedNo default extracted.
Standard React/HTML attribute.
onClickMouseEventHandler<HTMLDivElement> | undefinedNo default extracted.
Standard React/HTML attribute.
Accessibility
- Name each navigation region and the optional aside.
- Verify the composition at narrow widths. Collapsing a sidebar and opening a mobile overlay are different interactions; choose the behavior your app needs.