panel/01-sidebar-toggle
A semantic content region alongside a responsive, collapsible navigation sidebar.
Loading interactive preview
import type { CSSProperties } from 'react';
import { Frame } from 'ui-lab-components/frame';
import { Panel } from 'ui-lab-components/panel';
const CELL_STYLE = {
'--fill': 'var(--background-900)',
'--stroke-color': 'var(--background-600)',
} as CSSProperties;
function FrameCell({ className, style }: { className?: string; style?: CSSProperties }) {
return (
<Frame pathStroke="dashed" className={className} style={{ ...CELL_STYLE, ...style }}>
<div className="size-full" />
</Frame>
);
}
function NavCells() {
return (
<div className="grid h-full w-full min-w-0 content-start gap-2 p-3">
{Array.from({ length: 4 }, (_, index) => <FrameCell key={index} style={{ height: 28 }} />)}
</div>
);
}
export default function Example() {
return (
<Panel collapseAt={480} spacing="none">
<Panel.Sidebar
id="navigation"
side="left"
size={184}
defaultOpen
aria-label="Navigation"
className="border-r border-background-700"
>
<NavCells />
</Panel.Sidebar>
<section className="flex min-w-0 flex-1 flex-col overflow-hidden">
<header className="flex shrink-0 items-center justify-between border-b border-background-700 px-2 py-2">
<div className="flex items-center gap-2">
<Panel.Toggle aria-controls="navigation">
<button aria-label="Toggle navigation" className="h-7 w-7 cursor-pointer rounded-sm bg-background-700 hover:bg-background-600" />
</Panel.Toggle>
<FrameCell className="shrink-0" style={{ width: 96, height: 16 }} />
</div>
<FrameCell className="shrink-0" style={{ width: 28, height: 28 }} />
</header>
<main className="grid min-h-0 min-w-0 flex-1 content-start gap-3 overflow-auto p-3">
<FrameCell style={{ height: 88 }} />
<div className="grid min-w-0 grid-cols-2 gap-3">
<FrameCell style={{ height: 88 }} />
<FrameCell style={{ height: 88 }} />
</div>
</main>
<footer className="flex shrink-0 justify-between border-t border-background-700 px-2 py-2">
<FrameCell className="shrink-0" style={{ width: 56, height: 16 }} />
<FrameCell className="shrink-0" style={{ width: 40, height: 16 }} />
</footer>
</section>
</Panel>
);
}