Drawer

A collapsible drawer navigation component with mobile toggle support.

The drawer 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. By default, drawers are closed on desktop and require a drawer_trigger or programmatic control to open.

Basic Drawer

Click the menu button to toggle the drawer. The drawer slides in from the left. Click anywhere outside the drawer to close it.

Basic Drawer
My App

Main content area

Click the Menu button to toggle the drawer.

Click outside the drawer to close it.

With Collapsible Submenu

Use drawer_submenu for collapsible sections within the drawer.

Collapsible Submenu
Navigation

Main content area

Click the Menu button to toggle the drawer.

Add header and footer slots for branding and secondary actions.

Header and Footer
S
Sutra UI

Main content area

Drawer has header branding, content sections, and a footer with settings.

Drawer Trigger

Use drawer_trigger to create a toggle button for the drawer.

Trigger Variants
Trigger Demo

Each trigger controls a different drawer:

Ghost → Left drawer
Outline → Right drawer

Programmatic Control

Control the drawer state from JavaScript using custom events:

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

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

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

Accessibility

The drawer 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"
  • Click outside to close functionality