Skip to main content

Drawer

A panel that slides up from the bottom edge of the screen for a short task, with a swipe down to close.

Desktop viewport
Tablet viewport
Mobile viewport

When to use

  • Show a short task or a set of choices from the bottom of a phone screen, where a thumb reaches it: filters, a share sheet, a quick form.
  • Prefer Popover with presentation="auto" for a task that sits next to its trigger on a large screen and becomes a drawer on a phone.
  • Prefer Sheet for a panel from the left or right edge, such as a detail view.
  • Prefer Dialog for a task that needs a centered modal window.

Swipe to close

The panel follows a finger or a mouse down one to one. A release past a quarter of its height, or a flick, closes it. A shorter drag springs back. A drag up stretches the panel against rubber-band resistance, and it stays on the bottom edge. The scrim fades with the drag. A press on a field, a menu trigger, selected text, or scrolled content does not start a drag, and on a touch screen Drawer.Body scrolls with the finger. Under reduced motion the drawer appears and leaves in place.

Set dismissible={false} on Drawer.Root while the drawer holds unsaved work: a swipe springs back, and Escape, back, and the scrim do nothing. Drawer.Close and the owner still close it. The browser still closes it on a second back with no press in between, so that a page cannot trap the user, and onOpenChange reports that close.

Layering and the keyboard

Drawer runs on the browser's modal <dialog>: the page is inert and stops scrolling, and focus returns to the trigger on close. Focus moves to the <dialog>, not to its first field, so the on-screen keyboard stays closed until the user taps a field. When the keyboard opens, the panel rises above it. The scrim is a light dim with no blur.

Floats composed inside portal into the drawer. Toasts and OverlayPrompt content move into it. A Sandbar slides away while the drawer is open, so it does not cover the drawer's actions. See Stacking layers.

Composition

Drawer.Root
├── Drawer.Trigger
└── Drawer.Content
    ├── Drawer.Header
    │   ├── Drawer.Title
    │   └── Drawer.Description
    ├── Drawer.Body
    └── Drawer.Footer
        └── Drawer.Close

API Reference

Drawer.Root

The stateful root. It renders no element.

PropTypeDefaultDescription
defaultOpen?booleanfalseThe open state on the first render, for an uncontrolled drawer.
open?booleanThe controlled open state. Pair it with onOpenChange.
onOpenChange?(open: boolean) => voidRuns when the drawer opens or closes.
dismissible?booleantrueWhether a swipe, Escape, back, or the scrim closes the drawer. With false, a swipe springs back.

Drawer.Trigger

The button that opens the drawer. All props of a <button>, plus asChild.

Data AttributeValueDescription
data-slot"drawer-trigger"On the trigger.

Drawer.Content

The panel: a modal <dialog> that slides up from the bottom edge, with a grab handle at its top. All props of a <div>, plus onOpenAutoFocus, onCloseAutoFocus, onEscapeKeyDown, onPointerDownOutside, and onInteractOutside.

It sets the CSS variables --drawer-swipe (how far a drag has moved the panel, from 0 to 1) and --drawer-keyboard-inset (the height of the on-screen keyboard) on the <dialog>.

Data AttributeValueDescription
data-slot"drawer-content"On the panel, with any composing part's chain ahead of it.
data-slot (positioner)"drawer-positioner"On the <dialog> around the panel.
data-slot (handle)"drawer-handle"On the grab handle at the top of the panel. Hidden from assistive technology.
data-slot (children)"drawer-children"On a display: contents wrapper around the children, after the handle.
data-openpresent while openPresence-only. On the <dialog> positioner and the panel. Drives the slide in.
data-closingpresent while the exit playsPresence-only. On the <dialog> positioner and the panel. Drives the slide out.
data-overlay""On the <dialog> positioner. A press on the scrim targets it.
data-mantle-modal-content""On the panel. Floats and an enclosing dialog find the panel by it.
data-mantle-scroll-lockpresent while openPresence-only. On <html>, while any modal dialog is open. The page stops scrolling.

Drawer.Header

The top of the drawer, for its title and description. All props of a <div>.

Data AttributeValueDescription
data-slot"drawer-header"On the header.

Drawer.Title

The accessible name of the drawer. Renders an h2, or its child with asChild.

Data AttributeValueDescription
data-slot"drawer-title"On the title.

Drawer.Description

The accessible description of the drawer. All props of a <div>, plus asChild.

Data AttributeValueDescription
data-slot"drawer-description"On the description.

Drawer.Body

The scrolling middle of the drawer. All props of a <div>.

Data AttributeValueDescription
data-slot"drawer-body"On the body.

Drawer.Footer

The actions at the bottom of the drawer. All props of a <div>.

Data AttributeValueDescription
data-slot"drawer-footer"On the footer.

Drawer.Close

A button that closes the drawer. All props of a <button>, plus asChild.

Data AttributeValueDescription
data-slot"drawer-close"On the close button.