Drawer
A fixed off-canvas panel for navigation or supporting content.
When to use
Use a drawer for supplementary navigation or a task panel that enters from an edge. Choose a modal drawer when the user must complete or dismiss it before returning to the page; a non-modal panel keeps the page available.
Default
Use .drawer for the panel and .is-open to show it.
<button
class="btn btn-primary btn-solid"
type="button"
aria-controls="drawer"
aria-expanded="false">
Open drawer
</button>
<div
id="drawer"
class="drawer"
role="dialog"
aria-modal="true"
aria-labelledby="drawer-title"
aria-hidden="true"
inert>
<div class="drawer-header">
<p id="drawer-title" class="drawer-title h6">Drawer</p>
<button class="icon-btn" type="button" aria-label="Close drawer">...</button>
</div>
<div class="drawer-body">...</div>
</div>
<div class="overlay"></div>Interactive
This modal demo traps focus and blocks the page. Non-modal drawers leave the page interactive.
When toggling .is-open, synchronize aria-expanded, aria-hidden and inert; move focus into the drawer and return it to the trigger on close.
<div class="drawer is-open">...</div>Accessibility and behavior
- Give the panel a visible heading and connect it with
aria-labelledby. Use dialog semantics andaria-modal="true"only when the application actually blocks background interaction. - Synchronize visibility,
inert,aria-hiddenand the trigger’saria-expanded. For modal drawers, move focus inside, contain Tab navigation, support Escape and return focus to the opener on close. - The Showcase implements these behaviors for its demo. The published package contains styles; consuming applications provide lifecycle and focus handling.
CSS variables
Override these base defaults on the listed selector after the library styles. Variants and states may replace them; global tokens follow the active theme.
| Token | Default | Purpose | Scope / state |
|---|---|---|---|
--drawer-width | 20rem | Preferred width. | .drawer |
--drawer-z-index | var(--z-index-drawer) | Stacking order. | .drawer |
--drawer-closed-translate-x | -100% | Horizontal off-screen position; end drawers and RTL change the sign. | .drawer |
--drawer-bg-color | var(--bg-surface) | Background color. | .drawer |
--drawer-border-width | var(--border-width) | Border thickness. | .drawer |
--drawer-border-color | var(--border-color) | Border color. | .drawer |
--drawer-header-padding-y | var(--spacer-2) | Header top and bottom padding. | .drawer |
--drawer-header-padding-x | var(--spacer-3) | Header left and right padding. | .drawer |
--drawer-body-padding | var(--spacer-3) | Body spacing. | .drawer |
--drawer-transition-duration | var(--transition-duration) | Duration of visual state transitions. | .drawer |
--drawer-transition-easing | var(--transition-easing) | Timing curve for visual state transitions. | .drawer |
--overlay-highlight | rgb(from var(--gray-800) r g b / 0.7) | Backdrop color behind the drawer. | .overlay |
--overlay-z-index | var(--z-index-overlay) | Stacking order. | .overlay |