Sidebar
Collapsible app sidebar with groups, badges and nested items.
Home
Installation
$ pnpm dlx shadcn@latest add @synccn/sidebarFirst time in this project? Connect synccn with one command.
Usage
import { Sidebar } from "@/components/ui/sidebar";<Sidebar groups={groups}>{(active) => …}</Sidebar>API reference
Generated from the component's TypeScript types, so it always matches the code.
Sidebar
Collapsible app sidebar. Collapsed mode shows icons with tooltips. groups: [{ label, items: [{ label, icon, badge?, children?: [{ label }] }] }]
- groupsrequired
SidebarGroup[]Navigation groups.
- header
React.ReactNodeShown at the top (hidden when collapsed).
- footer
React.ReactNode | ((collapsed: boolean) => React.ReactNode)Shown at the bottom; a function receives the collapsed state.
- defaultCollapsed
booleanDefault
falseStart in icon-only mode.
- active
stringLabel of the item active at first.
- onSelect
(label: string) => voidCalled when an item is chosen.
- children
React.ReactNode | ((active: string) => React.ReactNode)Main content; a function receives the active label.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
Components
- Tooltip for
Tooltip
Helpers
- lib/utilscn (merges class names)
npm packages
- clsx for cn()
- tailwind-merge for cn()
- lucide-react for ChevronRight, PanelLeft
Accessibility
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA attributes: aria-current, aria-expanded, aria-label