Overview
TheDrawerContent component is the main content container for the drawer. It handles drag gestures, snap point calculations, and focus management. This component must be used within a Drawer component.
Props
CSS classes for styling the drawer content. Typically includes positioning (
fixed, bottom-0), sizing, background color, and border radius.Whether to trap keyboard focus inside the drawer. When
true, Tab navigation is restricted to focusable elements within the drawer.Usage Examples
Basic Bottom Drawer
Side Drawer (Right)
With Custom Focus Behavior
Scrollable Content
Drag Behavior
TheDrawerContent component automatically handles:
- Mouse & Touch Events: Supports both desktop and mobile interactions
- Direction-Aware Dragging: Adapts to the drawer’s
directionprop - Snap Points: Automatically snaps to predefined positions when configured
- Dismissal Threshold: Closes drawer when dragged beyond 30% from the edge
- Smooth Animations: Eased transitions between positions
Drag Handle Areas
By default, dragging works on the entire drawer content except on interactive elements:<button>,<a>,<input>,<textarea>,<select>
data-drawer-drag attribute:
Focus Management
WhentrapFocus={true} (default):
- Auto-focus: First focusable element is focused when drawer opens
- Focus Trap: Tab/Shift+Tab cycles through focusable elements inside drawer
- Focus Restoration: Previously focused element is restored when drawer closes
trapFocus={false}:
- Tab navigation works normally across the entire page
- Focus is not automatically moved when drawer opens
Accessibility
The component automatically includes:role="dialog"- Identifies the drawer as a dialogaria-modal="true"- Indicates the drawer is modaltabindex="-1"- Allows programmatic focus
Styling
The component applies:z-index: 50- Ensures drawer appears above overlay (z-index: 40)touch-action: none- Prevents browser scroll during drag- Dynamic
transform- Handles positioning based on direction and drag state
Common Class Patterns
Bottom Drawer:Related Components
- Drawer - Main wrapper component
- DrawerHandle - Visual drag indicator
- DrawerVariants - Pre-styled variants
- DrawerHeader - Optional header component
- DrawerFooter - Optional footer component