Sidebar
Grouped side navigation for an app, with icons and counts.
import { Sidebar } from '@brand-studio/ui';
import { BookOpen, Flame, LayoutDashboard, Package, Users } from 'lucide-react';
export default function SidebarDemo() {
return (
<div style={{ width: 248, height: 380, border: '1px solid var(--bs-line-soft)', borderRadius: 12, overflow: 'hidden' }}>
<Sidebar
label="Roastery"
header={<strong style={{ display: 'block', padding: '4px 10px' }}>Still Roastery</strong>}
sections={[
{ items: [
{ label: 'Overview', href: '#overview', current: true, icon: <LayoutDashboard /> },
{ label: 'Orders', href: '#orders', badge: 12, icon: <Package /> },
{ label: 'Subscribers', href: '#subscribers', icon: <Users /> },
] },
{ label: 'Stock', items: [
{ label: 'Green beans', href: '#beans', badge: 4, icon: <Flame /> },
{ label: 'Roast log', href: '#log', icon: <BookOpen /> },
] },
]}
footer={<span style={{ fontSize: 13, color: 'var(--bs-muted)', padding: '0 10px' }}>Signed in as Mai</span>}
/>
</div>
);
}
Installation
pnpm add @brand-studio/ui
npm install @brand-studio/ui
yarn add @brand-studio/ui
Install the peer dependencies
npm install react react-dom
Import the stylesheet once
import '@brand-studio/ui/styles.css';
Wrap your app in a brand theme
import { BrandTheme, Sidebar } from '@brand-studio/ui';
import brand from './brand.json';
<BrandTheme palette={brand.tokens} mode="system">
{/* your app */}
</BrandTheme>
Usage
import { Sidebar } from '@brand-studio/ui';
<Sidebar
label="Roastery"
sections={[
{ items: [{ label: 'Overview', href: '/', current: true }] },
{ label: 'Stock', items: [{ label: 'Green beans', href: '/beans', badge: 4 }] },
]}
/>
Accessibility
- Renders an
<aside> holding a labelled <nav>. Each section heading labels its list, so screen readers announce the group.
- The current link gets
aria-current="page". Icons are decorative; counts are read as part of the link.
- The sidebar fills its parent's width and height. On narrow screens, hide it and pass the same links to Header or Mobile Navigation.
API Reference
| Prop | Type | Default |
|---|
sections | SidebarSection[] | – |
|---|
header? | React.ReactNode | – |
|---|
footer? | React.ReactNode | – |
|---|
label? | string | 'Sidebar' |
|---|
className? | string | '' |
|---|