# Sidebar
An app sidebar that collapses to icons or off the canvas and becomes a sheet on phones.
```ehtml Example
import {
SidebarProvider, Sidebar, SidebarHeader, SidebarContent, SidebarFooter, SidebarGroup,
SidebarGroupLabel, SidebarGroupContent, SidebarMenu, SidebarMenuItem, SidebarMenuButton,
SidebarRail, SidebarInset, SidebarTrigger,
} from "@elements/ui/sidebar";
import { Icon } from "@elements/ui/icon";
Application{item.title}
...
```
## Parts
| Part | What it is |
|---|---|
| `SidebarProvider` | The app frame: a flex row that holds the state, the shortcut, the cookie and the phone breakpoint. Every part inside finds it. |
| `Sidebar` | The panel. On desktop it collapses off the canvas or to icons; under 48rem it renders its content in a Sheet. |
| `SidebarTrigger` | An icon button that toggles the sidebar (the sheet on phones). Place it anywhere inside the provider. |
| `SidebarRail` | A thin strip on the sidebar's edge that toggles it on click. Not a tab stop. |
| `SidebarInset` | The `` beside the sidebar. With variant inset it becomes a raised card. |
| `SidebarHeader / SidebarFooter` | Sticky top and bottom sections. |
| `SidebarContent` | The scrolling middle. |
| `SidebarGroup` | A section with a label, an optional action and content. |
| `SidebarGroupLabel` | The group's heading; button makes it a button (for a CollapsibleTrigger). Hidden when collapsed to icons. |
| `SidebarGroupAction` | An icon button in the group's corner. |
| `SidebarGroupContent` | The group's body. |
| `SidebarMenu / SidebarMenuItem` | A `
` and `
` of menu rows. |
| `SidebarMenuButton` | A row: a link (href) or a button, with active state, sizes, an outline variant and a tooltip shown while collapsed to icons. |
| `SidebarMenuAction` | An icon button at the end of a row; showOnHover hides it until the row is hovered or focused. |
| `SidebarMenuBadge` | A count at the end of a row. |
| `SidebarMenuSkeleton` | A loading row, with an optional icon. |
| `SidebarMenuSub / SidebarMenuSubItem / SidebarMenuSubButton` | A nested list of links under a row. |
| `SidebarSeparator` | A rule between sections. |
| `SidebarInput` | A compact search field for the header. |
## Attributes
### SidebarProvider
| Attribute | Type | Default | Description |
|---|---|---|---|
| `open` | `boolean` (two-way) | `true` | Desktop: expanded or collapsed. Bind it to control it; the sidebar writes it back when the trigger, rail or shortcut toggles it. |
| `openMobile` | `boolean` (two-way) | `false` | Phone: the sheet is open. |
| `isMobile` | `boolean` (two-way) | `false` | Written by the provider: true under the breakpoint. Bind it to read it. |
| `shortcut` | `string` | `"b"` | Cmd (Mac) or Ctrl plus this key toggles the sidebar. Empty turns it off. |
| `cookie` | `string` | `"sidebar_state"` | Cookie that remembers open for a week, so the server can render it. Empty turns it off. |
| `cookieMaxAge` | `number` | `604800` | Seconds the cookie lasts. |
| `mobileBreakpoint` | `number` | `768` | Below this width (px) the sidebar is a sheet and an inset page drops its card. |
| `onOpenChange` | `(open: boolean) => void` | `() => {}` | The sidebar toggled itself (trigger, rail, shortcut). |
| `onOpenMobileChange` | `(open: boolean) => void` | `() => {}` | The phone sheet opened or closed itself. |
### Sidebar
| Attribute | Type | Default | Description |
|---|---|---|---|
| `side` | `"left" \| "right"` | `"left"` | Which edge. |
| `variant` | `"sidebar" \| "floating" \| "inset"` | `"sidebar"` | Flush with a border, floating with a shadow, or beside an inset main. |
| `collapsible` | `"offcanvas" \| "icon" \| "none"` | `"offcanvas"` | How it collapses: off the canvas, to icons, or not at all. |
| `dir` | `"ltr" \| "rtl" \| ""` | `""` | Text direction for the panel and the phone sheet; empty inherits. Pair rtl with side right for the start edge. |
| `label` | `string` | `"Sidebar"` | The navigation landmark's name, and the sheet's title on phones. |
### SidebarMenuButton, SidebarMenuSubButton
| Attribute | Type | Default | Description |
|---|---|---|---|
| `href` | `string` | `""` | Renders a link instead of a button. |
| `isActive` | `boolean` | `false` | The current page: highlighted, aria-current. |
### SidebarMenuButton
| Attribute | Type | Default | Description |
|---|---|---|---|
| `variant` | `"default" \| "outline"` | `"default"` | Plain or outlined row. |
| `size` | `"default" \| "sm" \| "lg"` | `"default"` | Row height. lg fits a two-line team or user row. |
| `tooltip` | `string` | `""` | Shown beside the row while the sidebar is collapsed to icons. |
| `disabled` | `boolean` | `false` | Not interactive. |
### SidebarMenuSubButton
| Attribute | Type | Default | Description |
|---|---|---|---|
| `size` | `"sm" \| "md"` | `"md"` | Text size. |
### SidebarMenuAction
| Attribute | Type | Default | Description |
|---|---|---|---|
| `showOnHover` | `boolean` | `false` | Hidden until the row is hovered or focused (desktop with a mouse). |
### SidebarGroupAction, SidebarMenuAction
| Attribute | Type | Default | Description |
|---|---|---|---|
| `label` | `string` | (required) | The icon button's accessible name. |
### SidebarGroupLabel
| Attribute | Type | Default | Description |
|---|---|---|---|
| `button` | `boolean` | `false` | Render a `