Skip to main content

Sidebar

StorybookView in Storybook

Explore interactive examples and all component variations in our Storybook.

The Sidebar component provides a flexible navigation panel that can slide in from any direction. Built with accessibility and responsive design in mind, it supports fixed and collapsible modes, multiple directions, and customizable content areas. Perfect for navigation menus, filters, settings panels, and any interface requiring additional space.

Basic Usage

Different Directions

My Application

Current page: dashboard

Filter Panel

Product Catalog

Product 1
Product 2
Product 3
Product 4
Product 5
Product 6

Block Click Outside

Note: This sidebar has `blockClickOutSide=true`, so clicking outside won't close it. You must use the close button.

Properties

PropertyTypeDefaultDescription
fixedboolean-Whether the sidebar is fixed (always visible) or collapsible.
isOpenboolean-Controlled open state of the sidebar.
onToggle(open: boolean) => void-Callback fired when the sidebar open state changes.
childrenReactNode-Sidebar content.
classNamestring-Additional CSS classes for the sidebar.
direction'top' | 'bottom' | 'left' | 'right' | 'full''left'Direction from which the sidebar slides in.
blockClickOutSidebooleanfalseWhether to prevent closing when clicking outside.

SidebarHeader

PropertyTypeDescription
childrenReactNodeHeader content (title, close button, etc.).
classNamestringAdditional CSS classes for the header.

SidebarBody

PropertyTypeDescription
childrenReactNodeMain body content.
classNamestringAdditional CSS classes for the body.

SidebarNav

PropertyTypeDescription
childrenReactNodeNavigation content (typically SidebarList).
classNamestringAdditional CSS classes for the nav.

SidebarList

PropertyTypeDescription
childrenReactNodeList items (SidebarListItem components).
classNamestringAdditional CSS classes for the list.

SidebarListItem

PropertyTypeDescription
childrenReactNodeList item content.
classNamestringAdditional CSS classes for the item.
onClick() => voidClick handler for the item.

SidebarFooter

PropertyTypeDescription
childrenReactNodeFooter content.
classNamestringAdditional CSS classes for the footer.

Direction Behavior

DirectionSlide AnimationDefault SizeUse Case
leftSlides from left edge288px widthPrimary navigation, menu
rightSlides from right edge288px widthFilters, settings, details
topSlides from top edge288px heightNotifications, search
bottomSlides from bottom edge288px heightActions, mobile menus
fullSlides from top-leftFull screenModal-like overlays

Accessibility

The Sidebar component includes comprehensive accessibility features:

  • Keyboard Navigation - Escape key to close, Tab navigation within sidebar
  • Focus Management - Automatic focus restoration when closed
  • Screen Reader Support - Proper ARIA attributes and hidden states
  • Semantic HTML - Uses proper nav, header, and footer elements
  • Click Outside - Configurable click-outside-to-close behavior
  • ARIA Labels - Descriptive labels for all interactive elements

Common Use Cases

The Sidebar component is perfect for:

  • Navigation Menus - Primary and secondary navigation systems
  • Filter Panels - Advanced filtering and search interfaces
  • Settings Panels - Application preferences and configuration
  • User Profiles - Profile information and account management
  • Shopping Carts - E-commerce cart and checkout flows
  • Notifications - System notifications and alerts
  • Help & Support - Documentation and help content
  • Mobile Menus - Responsive navigation for mobile devices

Best Practices

  1. Appropriate Direction - Choose the direction that makes sense for your layout
  2. Clear Purpose - Use descriptive headers to indicate sidebar purpose
  3. Consistent Behavior - Maintain consistent sidebar behavior across your app
  4. Mobile Optimization - Ensure sidebars work well on mobile devices
  5. Performance - Avoid heavy content that might cause layout shifts
  6. Accessibility - Test with screen readers and keyboard navigation
  7. Visual Hierarchy - Use proper spacing and typography in sidebar content
  8. State Management - Handle sidebar state consistently across components