Overview
Drawer is a slide-in panel component that appears from any edge of the screen. It includes swipe-to-dismiss functionality, backdrop overlay, and follows the same composable pattern as Dialog.Basic usage
Components
Drawer (Root)
The root component that manages drawer state and swipe behavior.The direction from which the drawer appears and can be swiped to dismiss.
Controls the open state of the drawer (controlled mode).
The initial open state in uncontrolled mode.
Callback fired when the open state changes.
Override the swipe direction. By default, matches the
side prop.Drawer.Trigger
A button that opens the drawer when clicked.When true, merges props with the immediate child element instead of rendering a button.
Drawer.Content
The drawer panel rendered in a portal with backdrop and viewport.The edge from which the drawer slides in.
Whether to show the close button in the top-right corner.
Props to pass to the backdrop overlay component.
Additional CSS classes for the drawer popup.
Drawer.Header
A container for the drawer header content.Drawer.Title
The accessible title element for the drawer. Required for accessibility.Drawer.Description
An optional description element that provides additional context.Drawer.Body
A container for the main drawer content.Drawer.Footer
A container for action buttons at the bottom of the drawer.Drawer.Close
A button that closes the drawer when clicked.When true, merges props with the immediate child element instead of rendering a button.
Usage examples
Drawer from left
Bottom drawer
Without close button
Controlled drawer
Swipe-to-dismiss
The drawer automatically enables swipe-to-dismiss functionality based on theside prop:
- Right drawer: Swipe right to dismiss
- Left drawer: Swipe left to dismiss
- Top drawer: Swipe up to dismiss
- Bottom drawer: Swipe down to dismiss
swipeDirection prop on the root component:
Accessibility features
- Focus trap: Focus is trapped within the drawer when open
- ESC to close: Press Escape to close the drawer
- Focus return: Focus returns to the trigger element when closed
- ARIA labels: Proper ARIA attributes including
aria-label="Drawer" - Close button: Includes accessible
aria-label="Close Drawer" - Swipe gestures: Native swipe-to-dismiss for touch devices
Trigger patterns
TheDrawer.Trigger component can be used in two ways:
- Default button: Renders a button element when no children are provided or
asChildis false - Custom trigger: Use
asChildprop to merge drawer trigger functionality with your own button component