Slide a panel in from an edge of the screen & swipe it away, built on Base UI.
View as MarkdownInstallation
Component API
| Prop | Type | Default | Description |
|---|---|---|---|
trigger | ReactNode | - | |
render | ReactElement | - | |
triggerIcon | ReactNode | - | A glyph beside the trigger's label. |
| A glyph beside the trigger's label. | |||
triggerIconPosition | leading | trailing | leading | Which end of the trigger triggerIcon sits at. |
Which end of the trigger triggerIcon sits at. | |||
open | boolean | - | |
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. | |||
defaultSnapPoint | number | string | - | |
snapPoint | number | 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. | |||
modal | boolean | "trap-focus" | true | true 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. | |||
swipeToOpen | boolean | false | A 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. | |||
title | string | - | 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. | |||
description | ReactNode | - | The body text, wired up by Base UI's own Drawer.Description. |
| The body text, wired up by Base UI's own Drawer.Description. | |||
children | ReactNode | - | |
closeLabel | string | - | |
side | bottom | top | left | right | bottom | The 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. | |||
handle | boolean | true | A 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. | |||
showClose | boolean | false | |
variant | edge | flyout | edge | edge 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. | |||
size | sm | md | lg | md | Padding 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. | |||
shape | none | rounded | pill | rounded | |
animated | boolean | true | |
className | string | - | |
focus | boolean | string | true | |
container | HTMLElement | 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.