Sidebar
An app shell sidebar with icon rail, submenus, hover actions, rail tooltips, skeletons, and a mobile drawer — spring-animated and themeable.
Installation#
pnpm dlx shadcn@latest add @davinciui/sidebarUsage#
Composition#
Use the following composition to build a Sidebar:
SidebarProvider
├── Sidebar
│ ├── SidebarHeader
│ ├── SidebarContent
│ │ └── SidebarGroup
│ │ ├── SidebarGroupLabel
│ │ └── SidebarGroupContent
│ │ └── SidebarMenu
│ │ └── SidebarMenuItem
│ │ └── SidebarMenuButton
│ └── SidebarFooter
└── SidebarInsetAPI Reference#
| Prop | Type | Default |
|---|---|---|
SidebarProviderProvides context for sidebar state. | Component | — |
SidebarSidebar container. | Component | — |
SidebarTriggerButton to toggle sidebar with state-morphing icon. | Component | — |
Sidebar · expandOnHoverIcon rail expands on hover, settles back on leave (desktop). | boolean | false |
SidebarProvider · persistKeyPersist open state in a 7-day cookie under this name. | string | — |
SidebarHeaderHeader section. | Component | — |
SidebarFooterFooter section. | Component | — |
SidebarContentMain content area. | Component | — |
SidebarGroupGroup container. | Component | — |
SidebarMenuMenu list. | Component | — |
SidebarMenuButtonMenu item button with active pill, badge, and submenu chevron. | Component | — |
SidebarMenuButton · tooltipRail tooltip, auto from text labels. Shows only when collapsed on desktop. | ReactNode | — |
SidebarMenuAction · showOnHoverReveal the row action on hover/focus; always visible on touch. | boolean | false |
SidebarMenuSubSubmenu. | Component | — |
SidebarMenuBadgeBadge for menu item. | Component | — |
SidebarMenuSkeletonLoading skeleton. | Component | — |
SidebarRailRail for resizing/collapse. | Component | — |
useSidebarHook to access sidebar context. | hook | — |
classNameAdditional CSS classes. | string | — |
Accessibility#
SidebarTrigger exposes aria-expanded, Cmd or Ctrl+B toggles the rail, and the mobile drawer is a modal dialog with focus trapping, Escape to close, inert background, and trigger focus restoration. Collapsed group labels become aria-hidden.
Motion#
Uses framer-motion with useReducedMotion for the spring width morph, 0.36s drawer, staggered submenus, and label fades. Reduced motion makes width instant and shortens transitions. Expand on hover is pointer only.
View source
Keep in mind
Need a custom component?
I build bespoke UI components & websites tailored to your brand.

