Sidebar

A collapsible sidebar navigation component with mobile toggle support.

The sidebar provides a responsive navigation panel that can be toggled open/closed. It supports mobile overlay mode, desktop persistent mode, collapsible submenus, and active page highlighting.

Basic Sidebar
Main content area

With Collapsible Submenu

Use sidebar_submenu for collapsible sections within the sidebar.

Collapsible Submenu
Main content area

Add header and footer slots for branding and secondary actions.

Header and Footer
Main content area

Programmatic Control

Control the sidebar state from JavaScript using custom events:

Programmatic Control
// Toggle sidebar
document.dispatchEvent(new CustomEvent('sutra-ui:sidebar', {
  detail: { id: 'main-sidebar' }
}));

// Open sidebar
document.dispatchEvent(new CustomEvent('sutra-ui:sidebar', {
  detail: { id: 'main-sidebar', action: 'open' }
}));

// Close sidebar
document.dispatchEvent(new CustomEvent('sutra-ui:sidebar', {
  detail: { id: 'main-sidebar', action: 'close' }
}));

Accessibility

The sidebar component includes comprehensive accessibility features:

  • Uses semantic <aside> and <nav> elements
  • Proper ARIA labels and aria-hidden state
  • Sets inert attribute when closed to prevent keyboard navigation
  • Active page links marked with aria-current="page"