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.

HTML
<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.

HTML
<div class="drawer is-open">...</div>

Accessibility and behavior

  • Give the panel a visible heading and connect it with aria-labelledby. Use dialog semantics and aria-modal="true" only when the application actually blocks background interaction.
  • Synchronize visibility, inert, aria-hidden and the trigger’s aria-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.

TokenDefaultPurposeScope / state
--drawer-width20remPreferred width..drawer
--drawer-z-indexvar(--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-colorvar(--bg-surface)Background color..drawer
--drawer-border-widthvar(--border-width)Border thickness..drawer
--drawer-border-colorvar(--border-color)Border color..drawer
--drawer-header-padding-yvar(--spacer-2)Header top and bottom padding..drawer
--drawer-header-padding-xvar(--spacer-3)Header left and right padding..drawer
--drawer-body-paddingvar(--spacer-3)Body spacing..drawer
--drawer-transition-durationvar(--transition-duration)Duration of visual state transitions..drawer
--drawer-transition-easingvar(--transition-easing)Timing curve for visual state transitions..drawer
--overlay-highlightrgb(from var(--gray-800) r g b / 0.7)Backdrop color behind the drawer..overlay
--overlay-z-indexvar(--z-index-overlay)Stacking order..overlay