Overview
Sidebar provides a comprehensive sidebar navigation system with collapsible behavior, mobile responsive design, and rich composition patterns.
- Use it for application navigation and hierarchical content organization.
- Supports
leftandrightplacement. - Includes
sidebar,floating, andinsetvisual variants. - Features automatic mobile drawer conversion.
- Built-in keyboard shortcuts (Cmd/Ctrl+B to toggle).
SidebarProvider for state management.
Installation
Import
Basic Example
Advanced Example
Controlled State
API Reference
SidebarProvider
Required provider for sidebar state management.Initial open state (uncontrolled).
Controlled open state.
Callback when open state changes.
Sidebar
Main sidebar container.Which side the sidebar appears on.
Visual style variant.
Collapsible behavior:
offExamples hides completely, icon shows icon-only state, none disables collapsing.SidebarHeader
Header section at the top of the sidebar.SidebarContent
Main scrollable content area.SidebarFooter
Footer section at the bottom of the sidebar.SidebarGroup
Semantic grouping container for menu sections.SidebarGroupLabel
Label for a sidebar group.SidebarGroupContent
Content wrapper for group items.SidebarGroupAction
Action button positioned in the group header.SidebarMenu
Menu list container.Size of menu items:
xs | sm | md | lg | xl.SidebarMenuItem
Individual menu item container.SidebarMenuButton
Interactive menu button with icon support.Whether this menu item is active.
Tooltip content (shown when sidebar is collapsed).
Size override for this button.
Visual variant.
SidebarMenuBadge
Badge indicator for menu items.SidebarMenuAction
Action button within a menu item.SidebarMenuSub
Nested submenu container.SidebarMenuSubItem
Individual item within a submenu.SidebarMenuSubButton
Interactive button within a submenu.SidebarMenuSkeleton
Loading skeleton for menu items.SidebarInput
Input field styled for sidebar use.SidebarSeparator
Visual separator between sections.SidebarTrigger
Button to toggle sidebar visibility.SidebarRail
Clickable rail for expanding collapsed sidebar.SidebarInset
Main content area positioned beside the sidebar.useSidebar
Hook for accessing sidebar state and controls.Current visual state.
Whether sidebar is open.
Function to set open state.
Function to toggle sidebar.
Whether viewport is mobile.
Mobile drawer open state.
Function to set mobile drawer state.
Accessibility
- Sidebar includes proper semantic landmarks.
- Keyboard shortcut (Cmd/Ctrl+B) for quick toggling.
- Focus management when collapsing/expanding.
- Mobile version uses Sheet drawer with proper ARIA labels.
SSR and RSC Notes
- Sidebar is client-interactive (
"use client"). - Mobile detection uses
useIsMobilehook from@kuzenbo/hooks. - Cookie-based state persistence for sidebar preference.
Styling and Tokens
- Uses sidebar-specific tokens (
bg-sidebar,text-sidebar-foreground,border-sidebar-border). floatingvariant adds shadow and rounded corners.insetvariant adds margin for floating appearance.- Icon-only collapsed state shows tooltips on hover.
Troubleshooting
- Sidebar not appearing: ensure component is wrapped in
SidebarProvider. - Toggle not working: verify
SidebarTriggeris rendered and provider is present. - Mobile drawer not showing: check that Sheet component is properly imported.
- Tooltips not appearing when collapsed: ensure
tooltipprop is set onSidebarMenuButton.