Join our Discord Community

Drawer

A versatile drawer component for slide-out panels and mobile-first interfaces. Perfect for navigation menus, forms, and contextual actions.

Looking for a sleek way to add slide-out panels to your app? Drawers provide an elegant solution for mobile navigation, forms, and actions that need space without cluttering your main interface.

Interactive drawer

A drawer with interactive content and smooth animations:

Loading component...

Built on Vaul by Emil Kowalski, this drawer component brings native-like interactions with gesture support, smooth animations, and accessibility features.

npx shadcn@latest add drawer

Why drawers enhance user experience

Drawers offer intuitive interactions that users expect:

  • Mobile-first design - Natural gesture support for touch interfaces
  • Space efficient - Maximize content area while keeping actions accessible
  • Gesture friendly - Swipe to open, drag to close feels intuitive
  • Smooth animations - Physics-based animations that respond to user input
  • Multiple directions - Slide from bottom, top, left, or right as needed
  • Backdrop control - Click outside to close or prevent accidental dismissal
  • Keyboard accessible - Full keyboard navigation and screen reader support
  • Responsive ready - Combine with dialogs for desktop/mobile experiences

Essential drawer patterns

Simple confirmation drawer

Quick actions and confirmations work great in drawers:

Loading component...

Responsive dialog-drawer

Smart component that adapts to screen size:

Loading component...

Controlled drawer state

Programmatically control drawer visibility:

Loading component...

Multiple directions

Drawers can slide from any edge of the screen:

Loading component...

Nested drawers

Layer drawers for complex workflows:

Loading component...

API Reference

Drawer

The root component that manages drawer state and behavior.

PropTypeDefaultDescription
openbooleanfalseWhether the drawer is open
onOpenChange(open: boolean) => void-Callback when open state changes
defaultOpenbooleanfalseDefault open state (uncontrolled)
modalbooleantrueWhether to render as modal with backdrop
direction"top" | "bottom" | "left" | "right""bottom"Direction drawer slides from
dismissiblebooleantrueWhether drawer can be dismissed by user
shouldScaleBackgroundbooleantrueWhether to scale background content
snapPointsnumber[]-Snap points for drawer height (0-1)
activeSnapPointnumber-Currently active snap point
setActiveSnapPoint(snapPoint: number) => void-Set active snap point
childrenReact.ReactNode-Drawer content components

DrawerTrigger

Button or element that opens the drawer.

PropTypeDefaultDescription
asChildbooleanfalseRender as child element instead of button
childrenReact.ReactNode-Trigger content

DrawerContent

The main content area that slides in and out.

PropTypeDefaultDescription
classNamestring-Additional CSS classes
childrenReact.ReactNode-Content to display in drawer

DrawerHeader

Header section with title and description.

PropTypeDefaultDescription
classNamestring-Additional CSS classes
childrenReact.ReactNode-Header content (typically title and description)

DrawerTitle

Accessible title for the drawer.

PropTypeDefaultDescription
classNamestring-Additional CSS classes
childrenReact.ReactNode-Title text

DrawerDescription

Optional description for additional context.

PropTypeDefaultDescription
classNamestring-Additional CSS classes
childrenReact.ReactNode-Description text

DrawerFooter

Footer area for actions and controls.

PropTypeDefaultDescription
classNamestring-Additional CSS classes
childrenReact.ReactNode-Footer content (typically buttons)

DrawerClose

Button that closes the drawer.

PropTypeDefaultDescription
asChildbooleanfalseRender as child element instead of button
childrenReact.ReactNode-Close button content

Drawer Directions

DirectionBehaviorBest Use Cases
bottomSlides up from bottom edgeMobile forms, actions, confirmations
topSlides down from top edgeNotifications, secondary menus
leftSlides in from left edgeNavigation menus, filters
rightSlides in from right edgeShopping carts, settings panels

Gesture Controls

GestureAction
Tap triggerOpen drawer
Drag handleMove drawer position
Swipe downClose bottom drawer
Swipe upClose top drawer
Swipe rightClose left drawer
Swipe leftClose right drawer
Tap backdropClose drawer (if dismissible)
Escape keyClose drawer

Keyboard Navigation

KeyAction
EscapeClose drawer
TabMove to next focusable element
Shift + TabMove to previous focusable element
Space/EnterActivate focused element

Snap Points

Snap points allow drawers to stop at specific heights:

ValueDescription
0.5Half screen height
0.880% of screen height
1.0Full screen height

Best practices for drawers

Design drawers that feel natural and responsive:

  • Clear purpose - Each drawer should have a focused, specific task
  • Appropriate direction - Bottom for mobile actions, sides for navigation
  • Proper sizing - Don't make drawers too small or overwhelmingly large
  • Gesture support - Allow drag-to-dismiss where it makes sense
  • Loading states - Show loading indicators for async content
  • Responsive design - Consider dialog alternatives for desktop
  • Focus management - Trap focus inside modal drawers
  • Content scrolling - Handle overflow content gracefully
  • Performance - Lazy load content for better perceived performance