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.
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.
Main content area
Click the Menu button to toggle the drawer.
With Header and Footer
Add header and footer slots for branding and secondary actions.
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.
Each trigger controls a different drawer:
Programmatic Control
Control the drawer state from JavaScript using custom events:
// 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
inertattribute when closed to prevent keyboard navigation -
Active page links marked with
aria-current="page" - Click outside to close functionality