Browse docs
Browse docs
Full-page layout component that provides a responsive sidebar, top bar, and main content area. Handles sidebar open/collapsed state and adapts to mobile viewports automatically.
import { AppShell } from '@dashforge/ui';
import { useState } from 'react';
const navItems = [
{
id: 'dashboard',
label: 'Dashboard',
href: '/dashboard',
icon: <DashboardIcon />,
},
{
id: 'settings',
label: 'Settings',
href: '/settings',
icon: <SettingsIcon />,
children: [
{ id: 'account', label: 'Account', href: '/settings/account' },
{ id: 'security', label: 'Security', href: '/settings/security' },
],
},
];
export function App() {
const [navOpen, setNavOpen] = useState(true);
return (
<AppShell
navOpen={navOpen}
onNavOpenChange={setNavOpen}
navItems={navItems}
logo={<img src="/logo.svg" alt="Logo" />}
topBarContent={<UserMenu />}
>
{/* page content */}
</AppShell>
);
}| Prop | Type | Default | Description |
|---|---|---|---|
navOpen | boolean | — | Whether the sidebar is expanded. Required. |
onNavOpenChange | (open: boolean) => void | — | Callback when sidebar open state changes. Required. |
navItems | NavItem[] | — | Navigation tree. Required. |
navWidthExpanded | number | 240 | Sidebar width in pixels when expanded. |
navWidthCollapsed | number | 64 | Sidebar width in pixels when collapsed. |
logo | ReactNode | — | Logo rendered at the top of the sidebar. |
topBarContent | ReactNode | — | Content rendered in the right side of the top bar. |
children | ReactNode | — | Main page content. |
NavItem supports nested children for grouped navigation. Groups render as collapsible sections.AppShell does not manage routing — use href on nav items with your router's Link component via the LinkComponent prop.