Overview
The Sidebar component provides a vertical navigation panel that can be collapsed and expanded. It supports hierarchical navigation with groups, icons, and tooltips, making it ideal for complex application layouts.Use cases
- Display hierarchical application navigation
- Organize navigation items into logical groups
- Save screen space with collapsible functionality
- Provide contextual tooltips when collapsed
- Build dashboard and admin panel layouts
- Create file explorer or resource browser interfaces
Anatomy
The Sidebar component consists of:Sidebar- Root container with collapse functionalitySidebar.Header- Top section for branding or user infoSidebar.Main- Primary navigation areaSidebar.Footer- Bottom section for settings or actionsSidebar.Group- Navigation group with labelSidebar.Item- Individual navigation link
Props
Sidebar (root)
'left' | 'right'
default:"'left'"
Position of the sidebar on the screen.
boolean
default:"false"
When true, tooltips will not be shown for navigation items when the sidebar is collapsed.
boolean
default:"true"
When false, disables the collapse/expand functionality.
ReactNode
Custom tooltip message for the collapse/expand handle. Defaults to “Click to collapse” or “Click to expand”.
boolean
Controlled open state of the sidebar. Use with
onOpenChange for controlled behavior.boolean
default:"true"
Default open state for uncontrolled usage.
(open: boolean) => void
Callback fired when the sidebar open state changes.
string
Additional CSS class names to apply to the sidebar.
Sidebar.Header
string
Additional CSS class names to apply to the header section.
Sidebar.Main
string
Additional CSS class names to apply to the main navigation section.
Sidebar.Footer
string
Additional CSS class names to apply to the footer section.
Sidebar.Group
string
required
The label text for the navigation group.
ReactNode
Icon to display before the group label.
object
Object containing className overrides for different parts:
header- Group header containeritems- Group items containerlabel- Label texticon- Leading icon
string
Additional CSS class names to apply to the group.
Sidebar.Item
ReactNode
Icon to display before the item label. When collapsed and no icon is provided, an avatar with the first letter will be shown.
boolean
default:"false"
Indicates whether this item is currently active/selected.
boolean
default:"false"
When true, the item is disabled and cannot be interacted with.
ReactElement
Custom element to render instead of the default anchor tag. Useful for integration with routing libraries.
object
Object containing className overrides for different parts:
root- Item containerleadingIcon- Icon containertext- Label text
string
Additional CSS class names to apply to the item (legacy, use
classNames.root instead).Usage
Basic sidebar
With navigation groups
Controlled sidebar
With active state
With header and footer
Right-positioned sidebar
Non-collapsible sidebar
With Next.js Link
With disabled items
Accessibility
- Uses semantic
<aside>element withrole="navigation"attribute - Includes
aria-label="Navigation Sidebar"for screen readers - Collapse/expand handle is keyboard accessible with Enter and Space keys
- Each item has
role="menuitem"for proper navigation semantics - Active items use
aria-current="page"attribute - Disabled items use
aria-disabledattribute - Collapsed state is communicated via
aria-expandedattribute - Navigation groups have proper
aria-labelattributes - Tooltips provide context when sidebar is collapsed