Skip to content

Drawer

An edge-anchored overlay panel that slides in from any side of the viewport.

  • stable
  • since v0.1.0
  • 3.8 kB
  • overlay
  • modal
  • accessible

Uses role="dialog" aria-modal="true"; focus is trapped; Esc closes by default and restores focus to the trigger.

Preview
Open
tsx

DrawerContent accepts side="top" | "right" (default) | "bottom" | "left". Right is the canonical filter-panel placement; bottom is the canonical mobile sheet.

Preview
Open
tsx

Pass size="sm" | "md" (default) | "lg" | "xl" | "full". For top / bottom, size sets the height; for left / right, size sets the width.

Preview
Open
tsx

Embed a form inside DrawerContent. Submit closes the drawer; DrawerClose cancels.

Preview
Open
tsx

Drive the open state externally to coordinate with route changes or async work.

Preview
Open
tsx
PropTypeDefaultDescription
side
"top"|"right"|"bottom"|"left"
right
Edge the drawer slides in from.
size
"sm"|"md"|"lg"|"xl"|"full"
md
Drawer breadth.
closeOnOverlayClick
boolean
true
closeOnEscape
boolean
true
showCloseButton
boolean
true
closeLabel
string
Close
container
HTMLElement|(() => HTMLElement)
hideOverlay
boolean
false
  • DrawerContent renders with role="dialog" and aria-modal="true", sharing the same focus-trap + scroll-lock kit as Dialog.
  • Focus is trapped inside the drawer while open and returned to the trigger on close.
  • Esc closes by default (closeOnEscape={true}); suppress with closeOnEscape={false}.
  • Clicking the backdrop closes by default (closeOnOverlayClick={true}); suppress with closeOnOverlayClick={false}.
  • The built-in close icon button is labelled via closeLabel (“Close” by default); hide with showCloseButton={false}.
  • Use side="right" for filter and detail panels; side="bottom" works well as a mobile sheet.
  • Pair with route-based open state so deep links restore the drawer on refresh.
  • Use hideOverlay when stacking a drawer on top of an already-modal surface.
  • For multi-step flows, prefer Dialog to keep a single focused task in view.