Skip to main content

Drawer

Slide a panel in from an edge of the screen & swipe it away, built on Base UI.

View as Markdown

Installation

Component API

PropTypeDefaultDescription
triggerReactNode-
renderReactElement-
triggerIconReactNode-A glyph beside the trigger's label.
A glyph beside the trigger's label.
triggerIconPositionleading | trailingleadingWhich end of the trigger triggerIcon sits at.
Which end of the trigger triggerIcon sits at.
openboolean-
onOpenChange(open: boolean) => void-Called whenever it opens or closes, controlled or not.
Called whenever it opens or closes, controlled or not.
snapPoints(number | string)[]-Heights a bottom or top drawer rests at, as a fraction of the screen or a length.
Heights a bottom or top drawer rests at, as a fraction of the screen or a length.
defaultSnapPointnumber | string-
snapPointnumber | string | null-Controlled snap point, with onSnapPointChange.
Controlled snap point, with onSnapPointChange.
onSnapPointChange(snapPoint: number | string | null) => void-Called whenever it moves to another snap point.
Called whenever it moves to another snap point.
modalboolean | "trap-focus"truetrue locks the page while it is open; false leaves the page usable; trap-focus keeps focus inside but leaves the page scrolling.
true locks the page while it is open; false leaves the page usable; trap-focus keeps focus inside but leaves the page scrolling.
swipeToOpenbooleanfalseA strip along its edge, marked with a grab bar, that opens it with a swipe.
A strip along its edge, marked with a grab bar, that opens it with a swipe.
titlestring-The drawer's heading, wired up by Base UI's own Drawer.Title.
The drawer's heading, wired up by Base UI's own Drawer.Title.
descriptionReactNode-The body text, wired up by Base UI's own Drawer.Description.
The body text, wired up by Base UI's own Drawer.Description.
childrenReactNode-
closeLabelstring-
sidebottom | top | left | rightbottomThe edge it slides in from, and the direction a swipe closes it.
The edge it slides in from, and the direction a swipe closes it.
handlebooleantrueA grab bar on the edge facing the page, for a bottom or top drawer.
A grab bar on the edge facing the page, for a bottom or top drawer.
showClosebooleanfalse
variantedge | flyoutedgeedge sits against the side it slides from; flyout floats 12px clear of every edge.
edge sits against the side it slides from; flyout floats 12px clear of every edge.
sizesm | md | lgmdPadding and text size of the trigger and the close button, on the same scale as Button.
Padding and text size of the trigger and the close button, on the same scale as Button.
shapenone | rounded | pillrounded
animatedbooleantrue
classNamestring-
focusboolean | stringtrue
containerHTMLElement | null-

Usage

Nesting

A Drawer placed in another's children opens on top of it. A bottom or top drawer steps back behind the new one, which needs the nested state.

DrawerIndent

Wrap the app in DrawerIndent so the page steps back while a drawer is open. It needs the indented state.