Installation
Structure
ASidebar component is composed of the following parts:
SidebarProvider- Handles collapsible stateSidebar- The sidebar containerSidebarHeaderandSidebarFooter- Sticky at the top and bottomSidebarContent- Scrollable content areaSidebarGroup- Section within the contentSidebarTrigger- Button to toggle the sidebar
Usage
Component API
SidebarProvider
Provides sidebar context and state management.defaultOpen- Default open state (default:true)open- Controlled open stateonOpenChange- Callback when open state changes
Sidebar
Main sidebar container.side- Which side the sidebar appears onvariant- Visual variant of the sidebarcollapsible- How the sidebar collapses
useSidebar Hook
Access sidebar state and controls.SidebarHeader
Sticky header section.SidebarFooter
Sticky footer section.SidebarContent
Scrollable content container.SidebarGroup
Groups related sidebar items.SidebarMenu
Menu list container.SidebarMenuItem
Individual menu item.SidebarMenuButton
Clickable menu button.SidebarTrigger
Button to toggle sidebar.Examples
Basic Sidebar
Collapsible to Icons
Right Side
Floating Variant
Inset Variant
Controlled Sidebar
Custom Width
With Collapsible Groups
Theming
Customize sidebar colors with CSS variables:Keyboard Shortcuts
Cmd+B(Mac) orCtrl+B(Windows) - Toggle sidebar
Accessibility
- Keyboard navigation support
- Focus management
- ARIA labels and roles
- Screen reader announcements