# Sidebar

> A collapsible app sidebar with icons and badges.

- Category: [Navigation](https://tarve.dev/docs.md#navigation)
- Import: `import { Sidebar } from "@tarve/core";`
- Props type: `SidebarProps`
- Source: [packages/core/src/advanced-controls.ts:270](https://github.com/omarcosr/tarve/blob/main/packages/core/src/advanced-controls.ts#L270)

## Usage

```tsx title="Sidebar.tsx"
import { Badge, Sidebar, Text } from "@tarve/core";

let page = "inbox";
let collapsed = false;

<Sidebar
  value={page}
  collapsed={collapsed}
  header={<Text weight={700}>Acme</Text>}
  items={[
    { value: "inbox", label: "Inbox", icon: "mail", badge: <Badge>4</Badge> },
    { value: "starred", label: "Starred", icon: "star" },
    { value: "settings", label: "Settings", icon: "settings" },
  ]}
  onValueChange={(value) => {
    page = value;
  }}
  onCollapsedChange={(value) => {
    collapsed = value;
  }}
/>
```

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `items` (required) | `readonly SidebarItem[]` | — |  |
| `collapsed` | `boolean` | `false` |  |
| `collapsedWidth` | `number` | `64` |  |
| `footer` | `Child` | — |  |
| `header` | `Child` | — |  |
| `onCollapsedChange` | `(collapsed: boolean) => void` | — |  |
| `onValueChange` | `(value: string) => void` | — |  |
| `value` | `string` | — |  |
| `width` | `number` | `248` |  |

## Common props

Shared by every component (descriptions: https://tarve.dev/docs.md#common-props): `children`, `class`, `className`, `highlight`, `id`, `key`, `motionFrom`, `onHighlight`, `onPaste`, `onPointerLeave`, `onPointerMove`, `onSize`, `onTransitionEnd`, `rovingGroup`, `style`.

## Types

```ts title="SidebarItem"
interface SidebarItem {
  value: string;
  label: string;
  icon?: IconName;
  disabled?: boolean;
  badge?: Child;
}
```

Previous: [AppMenuBar](https://tarve.dev/docs/components/AppMenuBar.md) · Next: [Carousel](https://tarve.dev/docs/components/Carousel.md)

---

Tarve v0.13.8 · HTML version: https://tarve.dev/docs/components/Sidebar · Index for agents: https://tarve.dev/llms.txt
