# Sidebar

> Grouped side navigation for an app, with icons and counts.

```tsx
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

```sh
npm install @brand-studio/ui
```

React 18 or 19 is a peer dependency. Import the stylesheet once and wrap the app in a brand theme:

```tsx
import '@brand-studio/ui/styles.css';
import { BrandTheme, Sidebar } from '@brand-studio/ui';
import brand from './brand.json';

<BrandTheme palette={brand.tokens} mode="system">
  {/* your app */}
</BrandTheme>
```

## Usage

```tsx
import { Sidebar } from '@brand-studio/ui';
```

```tsx
<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` | `''` |

Source: https://brandstudio.js.org/docs/components/sidebar/
