Sidebar
Explore the Sidebar component and try its interactive examples.
Preview
Installation
Install the component source via shadcn Registry, the BIU CLI, or as an npm package.
pnpm dlx shadcn add @biudev/sidebarFirst time using @biudev? Map "@biudev": "https://ui.biu.dev/r/0.1.0/{name}.json" under registries in your components.json (see setup).
Usage
Start with this example, then adjust the import path for your project.
"use client";
import { useState } from "react";
import { Sidebar } from "@/components/ui/biu/sidebar";
export function Example() {
const [active, setActive] = useState("customers");
return (
<Sidebar
activeId={active}
onSelect={setActive}
groups={[
{
id: "main",
label: "Workspace",
items: [
{ id: "overview", label: "Overview" },
{ id: "customers", label: "Customers", badge: 12 },
],
},
]}
/>
);
}Examples
Try each example or switch to its code.
API reference
Properties and defaults from the component source. An asterisk marks a required property; a dash means no explicit default.
SidebarItemStatus
Also accepts properties from 'online' & 'busy' & 'away' & 'offline'.
Some properties depend on the variant; consult the source for the full union.
'online' | 'busy' | 'away' | 'offline'SidebarSubItem
| Property | Type | Default | Description |
|---|---|---|---|
id * | string | — | Unique sub-item identifier. |
label * | string | — | Visible link or button label. |
href | string | — | Optional anchor destination. |
badge | React.ReactNode | — | Optional trailing counter or tag badge. |
disabled | boolean | — | Disables interaction when `true`. |
onSelect | () => void | — | Fired when this sub-item is selected. |
SidebarItem
| Property | Type | Default | Description |
|---|---|---|---|
id * | string | — | Unique navigation item identifier. |
label * | string | — | Visible navigation label. |
icon | React.ReactNode | — | Optional leading 16px icon. |
href | string | — | Optional anchor destination (ignored when nested `children` are present). |
badge | React.ReactNode | — | Optional trailing counter or status badge. |
shortcut | string | — | Optional trailing keyboard shortcut hint (e.g. `'G I'`). |
status | SidebarItemStatus | — | Optional live presence dot (e.g. for agents or teammates). |
dotColor | string | — | Optional custom project/category dot color (e.g. `'#3b82f6'`). |
action | React.ReactNode | — | Optional trailing action slot revealed smoothly on row hover/focus. |
disabled | boolean | — | Disables interaction when `true`. |
onSelect | () => void | — | Fired when this item is selected. |
children | SidebarSubItem[] | — | Optional nested sub-navigation links with smooth tree expand/collapse. |
defaultOpen | boolean | — | Initial expanded state for nested children. |
SidebarGroup
| Property | Type | Default | Description |
|---|---|---|---|
id * | string | — | Unique group identifier. |
label | string | — | Optional uppercase section heading. |
badge | React.ReactNode | — | Optional compact counter displayed beside the group heading. |
action | React.ReactNode | — | Optional trailing action button rendered in the group heading row (e.g. a `+` button). |
collapsible | boolean | — | Enables collapsible section toggle when `true`. |
defaultOpen | boolean | — | Initial expanded state when `collapsible` is `true`. Defaults to `true`. |
items * | SidebarItem[] | — | Navigation items belonging to this group. |
SidebarSearchConfig
| Property | Type | Default | Description |
|---|---|---|---|
mode | 'filter' | 'trigger' | — | `'filter'` filters sidebar items inline (default); `'trigger'` renders a command-palette trigger button. |
placeholder | string | — | Input or trigger placeholder text. Defaults to `'Search…'`. |
shortcut | string | — | Optional keyboard hint keycap displayed in `'trigger'` mode (e.g. `'⌘K'`). |
value | string | — | Controlled search query in `'filter'` mode. |
onValueChange | (value: string) => void | — | Fired when the inline filter query changes. |
onTrigger | () => void | — | Fired when clicking the search button in `'trigger'` mode. |
label | string | — | Accessible label for the search field or button. |
SidebarRailItem
| Property | Type | Default | Description |
|---|---|---|---|
id * | string | — | Unique primary rail section identifier. |
label * | string | — | Short label rendered below the rail icon. |
icon * | React.ReactNode | — | Primary rail icon. |
badge | number | string | — | Optional numeric or short notification badge on the rail icon. |
onSelect | () => void | — | Fired when this rail section is clicked. |
SidebarRailConfig
| Property | Type | Default | Description |
|---|---|---|---|
brand | React.ReactNode | — | Optional workspace mark or avatar rendered at the top of the primary rail. |
items * | readonly SidebarRailItem[] | — | Vertical section switches rendered in the primary icon rail. |
activeId | string | — | Controlled active rail section id. |
defaultActiveId | string | — | Uncontrolled initial active rail section id. |
onSelect | (id: string) => void | — | Fired when switching rail sections. |
footer | React.ReactNode | — | Optional footer slot pinned to the bottom of the primary rail. |
width | number | — | Width of the primary rail in pixels. Defaults to `52`. |
'aria-label' | string | — | Accessible label for the primary rail navigation landmark. |
SidebarWorkspaceOption
| Property | Type | Default | Description |
|---|---|---|---|
id * | string | — | Unique workspace identifier. |
name * | string | — | Display name shown in the header and switcher menu. |
plan | string | — | Optional plan or member count subtitle (e.g. `'Pro · 12 members'`). |
monogram | string | — | Optional single-letter monogram override inside the workspace mark. |
icon | React.ReactNode | — | Optional custom icon element rendered inside the workspace mark. |
SidebarWorkspaceConfig
| Property | Type | Default | Description |
|---|---|---|---|
name * | string | — | Active workspace display name. |
monogram | string | — | Optional monogram letter override inside the brand mark. |
icon | React.ReactNode | — | Optional custom logo element rendered inside the brand mark. |
plan | string | — | Optional workspace plan label. |
options | readonly SidebarWorkspaceOption[] | — | Switchable workspaces displayed in a floating dropdown menu. |
activeId | string | — | Controlled active workspace id. |
defaultActiveId | string | — | Uncontrolled initial active workspace id. |
onSelect | (id: string) => void | — | Fired when switching to another workspace option. |
menuItems | DropdownMenuItem[] | — | Extra menu actions appended below workspace options (e.g. Settings, Create workspace). |
SidebarAccountConfig
| Property | Type | Default | Description |
|---|---|---|---|
name * | string | — | Signed-in user name shown in the footer button and floating menu header. |
email | string | — | Optional email or role caption shown inside the floating account menu. |
avatar | string | — | Optional avatar image URL. |
color | string | — | Optional avatar accent color. |
status | SidebarItemStatus | — | Optional live presence indicator on the avatar. |
badge | string | — | Optional plan or role badge shown in the floating menu header (e.g. `'Pro'`). |
header | React.ReactNode | — | Optional custom header rendered at the top of the floating account dropdown. |
menuItems | DropdownMenuItem[] | — | Interactive items rendered inside the floating account dropdown menu. |
SidebarPromoItem
| Property | Type | Default | Description |
|---|---|---|---|
id * | string | — | Unique promo card identifier. |
eyebrow * | string | — | Compact eyebrow label (e.g. `'NEW'`, `'CHANGELOG'`). |
title * | string | — | Headline displayed in the promo card. |
linkLabel | string | — | Optional action link label (e.g. `'Read notes'`). |
onAction | () => void | — | Fired when the user clicks the promo card link. |
SidebarVariant
Also accepts properties from 'flat' & 'inset' & 'floating'.
Some properties depend on the variant; consult the source for the full union.
'flat' | 'inset' | 'floating'SidebarCollapseMode
Also accepts properties from 'rail' & 'hide'.
Some properties depend on the variant; consult the source for the full union.
'rail' | 'hide'SidebarProps
| Property | Type | Default | Description |
|---|---|---|---|
groups * | SidebarGroup[] | — | Grouped navigation sections rendered inside the scrollable sidebar body. |
activeId | string | — | Controlled active item or sub-item id. |
defaultActiveId | string | — | Uncontrolled initial active item id. |
onSelect | (id: string) => void | — | Fired when any item or sub-item is selected. |
collapsed | boolean | — | Controlled collapsed state. |
defaultCollapsed | boolean | false | Uncontrolled initial collapsed state. Defaults to `false`. |
onCollapsedChange | (collapsed: boolean) => void | — | Fired when the collapsed state toggles. |
collapsible | boolean | true | Shows the built-in collapse toggle button in the header. Defaults to `true`. |
collapseMode | SidebarCollapseMode | 'rail' | How collapsing behaves: `'rail'` shrinks to an icon rail (default), `'hide'` hides the panel while keeping any primary `rail`. |
variant | SidebarVariant | 'flat' | Visual chrome variant: `'flat'`, `'inset'`, or `'floating'`. Defaults to `'flat'`. |
shortcut | boolean | false | Enable Cmd/Ctrl+B keyboard shortcut to toggle collapsed state. |
workspace | SidebarWorkspaceConfig | — | Optional workspace switcher header with monogram/logo mark that cross-fades to the expand icon on collapsed hover. |
search | boolean | SidebarSearchConfig | — | Optional built-in search box (`true` / `{ mode: 'filter' }`) or command trigger (`{ mode: 'trigger', shortcut: '⌘K' }`); collapses into a search icon button in rail mode. |
promos | readonly SidebarPromoItem[] | — | Optional dismissible stacked promo/changelog deck rendered above the footer in expanded mode. |
onDismissPromo | (id: string) => void | — | Fired when a promo card is dismissed. |
account | SidebarAccountConfig | — | Optional interactive user account footer button with a floating dropdown menu (shrinks to clickable avatar in collapsed rail). |
rail | SidebarRailConfig | — | Optional persistent primary icon rail (dual-rail layout as in Kanban / Slack / Linear workspaces). |
resizable | boolean | false | Enables pointer-drag resizing along the sidebar's right edge. Defaults to `false`. |
minWidth | number | 180 | Minimum drag-resize width in pixels. Defaults to `180`. |
maxWidth | number | 360 | Maximum drag-resize width in pixels. Defaults to `360`. |
onWidthChange | (width: number) => void | — | Fired while drag-resizing the sidebar width. |
width | number | 236 | Expanded sidebar panel width in pixels. Defaults to `236`. |
collapsedWidth | number | 56 | Collapsed mini-rail width in pixels when `collapseMode="rail"`. Defaults to `56`. |
header | React.ReactNode | ((collapsed: boolean) => React.ReactNode) | — | Custom header slot or render function receiving `collapsed` (used when `workspace` is not set). |
footer | React.ReactNode | ((collapsed: boolean) => React.ReactNode) | — | Custom footer slot or render function receiving `collapsed` (rendered alongside or instead of `account`). |
collapseLabel | string | 'Collapse sidebar' | Accessible label for the collapse button. |
expandLabel | string | 'Expand sidebar' | Accessible label for the expand button. |
dismissPromoLabel | string | 'Dismiss notice' | Accessible label for the promo card dismiss button. |
emptySearchText | string | 'No matching items' | Message shown when inline search filters out every item. |
className | string | — | Additional CSS class name applied to the root element. |
style | React.CSSProperties | — | Inline CSS styles applied to the root element. |
'aria-label' | string | 'Workspace navigation' | Accessible label for assistive technologies. |
Source
Review a formatted version of the component source used by the Registry.