Drawer
A drawer is a panel that slides in from the edge of the screen. It’s often used for navigation or displaying contextual information without navigating away from the current page.Import
Basic Usage
Sub-components
Root
Groups all parts of the drawer. Doesn’t render its own HTML element. Key Props:open(boolean): Whether the drawer is currently opendefaultOpen(boolean): Whether the drawer is initially open (default:false)modal(boolean | ‘trap-focus’): Determines if the drawer enters a modal state (default:true)onOpenChange((open: boolean, eventDetails) => void): Event handler called when the drawer is opened or closedonOpenChangeComplete((open: boolean) => void): Event handler called after animations completedisablePointerDismissal(boolean): Determines whether the drawer should close on outside clicks (default:false)swipeDirection(‘up’ | ‘down’ | ‘left’ | ‘right’): The swipe direction used to dismiss the drawer (default:'down')snapPoints(Array): Snap points used to position the drawer (numbers 0-1 for fractions, >1 for pixels, or strings like'148px')snapPoint(number | string | null): The currently active snap point (controlled)defaultSnapPoint(number | string | null): The initial snap point value when uncontrolledsnapToSequentialPoints(boolean): Disables velocity-based snap skipping (default:false)onSnapPointChange((snapPoint, eventDetails) => void): Callback fired when the snap point changeshandle(DialogHandle): A handle to associate the drawer with an external triggeractionsRef(React.RefObject): A ref to imperative actions (unmount,close)
Trigger
The button that opens the drawer.Portal
Portals the drawer content to a different part of the DOM.Backdrop
The backdrop that covers the screen when the drawer is open.Popup
The container for the drawer content.Content
The main content area of the drawer.Title
An accessible title for the drawer.Description
An accessible description for the drawer.Close
A button that closes the drawer.Viewport
Defines the viewport element to which the drawer is confined.Provider
Provides drawer context to nested drawers.Indent
Creates an indent effect for nested drawers.IndentBackground
The background for the indent effect.Styling Example
Key Features
- Swipe to dismiss in configurable directions
- Snap points for partial drawer states
- Nested drawer support with indent effects
- Android back gesture support (Chromium-only)
- Smooth animations with spring physics
- Keyboard navigation support
Accessibility
- Has
role="dialog"to identify it as a dialog - Title and description are automatically linked via
aria-labelledbyandaria-describedby - Focus is trapped within the drawer when modal
- The backdrop and outside elements are inert when the drawer is modal
- Pressing Escape closes the drawer
- Android back button/gesture support via CloseWatcher API