Drawer

A panel that slides in from screen edges. Extends the Dialog pattern with slide animations and edge positioning.

Setup

import { Drawer } from '@fragments-sdk/ui';

Examples

Default

Right-side drawer with header, body, and footer

Loading preview...

Left Side

Left-side drawer for navigation

Loading preview...

Bottom Sheet

Bottom drawer for mobile-style actions

Loading preview...

With Form

Drawer with a form layout

Loading preview...

Props

PropTypeDefaultDescription
childrenRequirednodeNot setDrawer content (use Drawer.Content, Drawer.Header, etc.)
openbooleanNot setControlled open state
defaultOpenbooleanfalseDefault open state (uncontrolled)
onOpenChangefunctionNot setCalled when open state changes
onOpenChangeCompletefunctionNot setCalled after open/close animation completes
modaluniontrueWhether to render as modal (blocks interaction with rest of page)
swipeDirectionenumupdownleftrightderived from `side` prop on ContentSwipe direction to dismiss.
snapPointsarrayNot setPreset snap-point heights for bottom-sheet drawers
disablePointerDismissalbooleanNot setDisable outside-click dismissal

Usage Guidelines

When to use

  • Side panels for editing or creating content
  • Mobile-style bottom sheets for actions
  • Navigation panels that slide in from the left
  • Detail views that overlay the main content

When not to use

  • Centered modal dialogs (use Dialog)
  • Non-blocking notifications (use Toast)
  • Permanent side navigation (use Sidebar)
  • Small contextual menus (use Menu or Popover)

Best practices

  • Default to right side for content editing and forms
  • Use left side for navigation drawers
  • Use bottom for mobile-style action sheets
  • Provide clear close affordance (X button or cancel)
  • Keep drawer content focused on a single task
  • Drawer.Trigger and Drawer.Close with asChild require a single valid React element child
  • Set Drawer.Content initialFocus={false} when custom focus management is needed
Accessibility
  • Automatically traps focus within the drawer
  • Closes on Escape key press
  • Returns focus to trigger element on close
  • Uses role="dialog" with proper aria attributes