Drawer

A panel that slides in from the edge of the screen, typically used for navigation or forms.

Loading...

Anatomy

Open drawerAdd a contactSave someone to your address book.triggergrabbertitledescriptionclose triggercontent
<Drawer.Root>
  <Drawer.Trigger />
  <Drawer.Backdrop />
  <Drawer.Positioner>
    <Drawer.Content>
      <Drawer.Grabber>
        <Drawer.GrabberIndicator />
      </Drawer.Grabber>
      <Drawer.Title />
      <Drawer.Description />
      <Drawer.CloseTrigger />
    </Drawer.Content>
  </Drawer.Positioner>
</Drawer.Root>

Examples

Swipe Direction

Use swipeDirection to set the edge the drawer slides in from.

Snap Points

Use snapPoints to define positions the drawer snaps to.

Set modal={false} to allow interaction with the page while the drawer is open.

Controlled

Use open and onOpenChange to control the open state.

Scrollable

No Drag Area

Add data-no-drag to an element inside the drawer so dragging can't start on it.

Non Draggable

Set draggable to false to disable drag-to-dismiss entirely.

Indent Background

Use Drawer.IndentBackground to indent the page behind the drawer.

Multiple Triggers

Give each Drawer.Trigger a value to share one drawer across triggers. onTriggerValueChange fires when a different trigger is activated.

Using the Root Provider

Use Drawer.RootProvider with the useDrawer hook to control the drawer from outside the component tree.

Guides

Styling by Swipe Direction

Drawer.Content exposes data-swipe-direction (up | down | left | right), the resolved physical direction the drawer slides in from. Use it for direction-aware styles, such as rounding the corners that face the viewport:

[data-drawer-content] {
  /* Top drawer */
  &[data-swipe-direction='up'] {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-bottom-left-radius: 16px;
    border-bottom-right-radius: 16px;
  }

  /* Bottom drawer */
  &[data-swipe-direction='down'] {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
  }

  /* Left drawer */
  &[data-swipe-direction='left'] {
    border-top-left-radius: 0;
    border-bottom-right-radius: 16px;
    border-top-left-radius: 16px;
    border-top-right-radius: 0;
  }

  /* Right drawer */
  &[data-swipe-direction='right'] {
    border-top-right-radius: 0;
    border-bottom-left-radius: 16px;
    border-top-left-radius: 0;
    border-top-right-radius: 16px;
  }
}

Preventing Overdrag Gaps

Dragging past the open position can leave a gap between the drawer and the viewport edge. Extend the background past its bounds with an ::after pseudo-element:

[data-drawer-content] {
  --bleed: 3rem;
  position: relative;

  /* Bleed effect */
  &::after {
    content: '';
    position: absolute;
    inset-inline: 0;
    top: 100%;
    height: var(--bleed);
    background-color: inherit;
    pointer-events: none;
  }
}

For side drawers, extend it horizontally:

[data-drawer-content] {
  /* Right drawer */
  &[data-swipe-direction='right']::after {
    inset-inline: auto;
    inset-block: 0;
    top: 0;
    left: 100%;
    width: var(--bleed);
    height: auto;
  }

  /* Left drawer */
  &[data-swipe-direction='left']::after {
    inset-inline: auto;
    inset-block: 0;
    top: 0;
    right: 100%;
    width: var(--bleed);
    height: auto;
  }
}

The ::after element inherits the background and sits just outside the content, so overdrag reveals it instead of a gap.

API Reference

Props

Root

PropDefaultType
closeOnEscapetrue
boolean

Whether to close the drawer when the escape key is pressed.

closeOnInteractOutsidetrue
boolean

Whether to close the drawer when the outside is clicked.

closeThreshold0.25
number

The threshold distance for dismissing the drawer.

defaultOpen
boolean

The initial open state of the drawer.

defaultSnapPoint
SnapPoint

defaultTriggerValue
string

The default trigger value (uncontrolled).

finalFocusEl
() => MaybeElement

Element to receive focus when the sheet is closed.

hideMode'display-none'
HideMode

How to hide content when mounted but not present. - `'display-none'`: HTML `hidden` attribute. Effects stay alive. - `'activity'`: React 19 `<Activity mode="hidden">`. Effects pause. Requires React 19+.

id
string

The unique identifier of the machine.

ids
ElementIds

The ids of the elements in the drawer. Useful for composition.

immediate
boolean

Whether to synchronize the present change immediately or defer it to the next frame

initialFocusEl
() => false | MaybeElement

Element to receive focus when the sheet is opened. Return `false` to skip moving focus, or `null` to use the default.

lazyMountfalse
boolean

Whether to enable lazy mounting

modaltrue
boolean

Whether to prevent pointer interaction outside the element and hide all content below it.

onEnterComplete
VoidFunction

Function called when the animation ends in the open state

onEscapeKeyDown
(event: KeyboardEvent) => void

Function called when the escape key is pressed

onExitComplete
VoidFunction

Function called when the animation ends in the closed state

onFocusOutside
(event: FocusOutsideEvent) => void

Function called when the focus is moved outside the component

onInteractOutside
(event: InteractOutsideEvent) => void

Function called when an interaction happens outside the component

onOpenChange
(details: OpenChangeDetails) => void

Function called when the open state changes.

onPointerDownOutside
(event: PointerDownOutsideEvent) => void

Function called when the pointer is pressed down outside the component

onRequestDismiss
(event: LayerDismissEvent) => void

Function called when this layer is closed due to a parent layer being closed

onSnapPointChange
(details: SnapPointChangeDetails) => void

Callback fired when the snap point changes.

onTriggerValueChange
(details: TriggerValueChangeDetails) => void

Callback when the active trigger value changes.

open
boolean

Whether the drawer is open.

present
boolean

Whether the node is present (controlled by the user)

preventDragOnScrolltrue
boolean

Whether to prevent dragging on scrollable elements. When enabled, the sheet will not start dragging if the user is interacting with a scrollable element.

preventScrolltrue
boolean

Whether to prevent scrolling behind the sheet when it's opened

restoreFocustrue
boolean

Whether to restore focus to the element that had focus before the sheet was opened.

role'dialog'
'dialog' | 'alertdialog'

The sheet's role

skipAnimationOnMountfalse
boolean

Whether to allow the initial presence animation.

snapPoint
SnapPoint

The currently active snap point.

snapPoints[1]
SnapPoint[]

The snap points of the drawer. Array of numbers or strings representing the snap points.

snapToSequentialPointsfalse
boolean

Whether the drawer should snap to sequential points when swiping.

stack
DrawerStack

Optional external store for coordinating app-level drawer stack visuals (e.g. indent and background layers).

swipeDirection'down'
SwipeDirection

The direction in which the drawer can be swiped.

swipeVelocityThreshold700
number

The threshold velocity (in pixels/s) for closing the drawer.

trapFocustrue
boolean

Whether to trap focus inside the sheet when it's opened.

triggerValue
string

The value of the trigger that currently controls the drawer.

unmountOnExitfalse
boolean

Whether to unmount on exit.

Backdrop

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<DrawerBackdropState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-drawer-backdrop]<uid>
[data-state]"open" | "closed"
[data-swiping]
[data-nested]Present when the backdrop is nested within another {{widget}}
[data-has-nested]Present when the backdrop has nested {{widget}}s
CSS VariableDescription
--drawer-swipe-progressThe drawer swipe progress value for the Backdrop
--drawer-swipe-strengthThe drawer swipe strength value for the Backdrop
--layer-indexThe index of the dismissable in the layer stack

CloseTrigger

Defines the <button> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

Content

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
draggabletrue
boolean

Whether the drawer content is draggable. If false, the drawer can only be dragged by the grabber.

render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<DrawerContentState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-drawer-content]<uid>
[data-state]"open" | "closed"
[data-expanded]Present when expanded
[data-swipe-direction]
[data-swiping]
[data-dragging]Present when in the dragging state
[data-nested-drawer-open]
[data-nested-drawer-swiping]
[data-nested]Present when the content is nested within another {{widget}}
[data-has-nested]Present when the content has nested {{widget}}s
CSS VariableDescription
--drawer-translateThe drawer translate value for the Content
--drawer-translate-xThe drawer translate x value for the Content
--drawer-translate-yThe drawer translate y value for the Content
--drawer-snap-point-offset-xThe offset position for drawer snap point
--drawer-snap-point-offset-yThe offset position for drawer snap point
--drawer-swipe-movement-xThe drawer swipe movement x value for the Content
--drawer-swipe-movement-yThe drawer swipe movement y value for the Content
--drawer-swipe-strengthThe drawer swipe strength value for the Content
--nested-drawersThe nested drawers value for the Content
--drawer-heightThe height of the Content
--drawer-frontmost-heightThe height of the Content
--layer-indexThe index of the dismissable in the layer stack
--nested-layer-countThe number of nested drawers

Description

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

GrabberIndicator

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

Grabber

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

IndentBackground

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

Indent

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

Positioner

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<DrawerPositionerState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-drawer-positioner]<uid>
[data-state]"open" | "closed"
[data-swipe-direction]
[data-nested]Present when the positioner is nested within another {{widget}}
[data-has-nested]Present when the positioner has nested {{widget}}s

RootProvider

PropDefaultType
value
UseDrawerReturn

asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
hideMode'display-none'
HideMode

How to hide content when mounted but not present. - `'display-none'`: HTML `hidden` attribute. Effects stay alive. - `'activity'`: React 19 `<Activity mode="hidden">`. Effects pause. Requires React 19+.

immediate
boolean

Whether to synchronize the present change immediately or defer it to the next frame

lazyMountfalse
boolean

Whether to enable lazy mounting

onEnterComplete
VoidFunction

Function called when the animation ends in the open state

onExitComplete
VoidFunction

Function called when the animation ends in the closed state

present
boolean

Whether the node is present (controlled by the user)

render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

skipAnimationOnMountfalse
boolean

Whether to allow the initial presence animation.

unmountOnExitfalse
boolean

Whether to unmount on exit.

SwipeArea

Defines the <div> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<DrawerSwipeAreaState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

AttributeDescription
[data-drawer-swipe-area]<uid>
[data-state]"open" | "closed"
[data-swiping]
[data-swipe-direction]
[data-disabled]Present when disabled

Title

Defines the <h2> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<EmptyState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

Trigger

Defines the <button> element.

AttributeDefaultType
asChild
boolean

Use the provided child element as the default rendered element, combining their props and behavior. Use `render` when you need the part's state: `render={(props, state) => <MyButton {...props} />}`.

For more details, read our Composition guide.
render
ReactElement<unknown, string | JSXElementConstructor<any>> | RenderFn<DrawerTriggerState>

Render the part as a custom element, combining their props and behavior. Pass an element to have the part's props merged into it, or a function to control the merge yourself and read the part's state.

value
string

The value that identifies this specific trigger

AttributeDescription
[data-drawer-trigger]<uid>
[data-value]The value of the item
[data-state]"open" | "closed"
[data-current]Present when current

Context

API

PropertyType
open
boolean

Whether the drawer is open.

modal
boolean

Whether the drawer is modal.

dragging
boolean

Whether the drawer is currently being dragged.

triggerValue
string | null

The value of the active trigger.

setTriggerValue
(value: string | null) => void

Set the active trigger value.

setOpen
(open: boolean, reason?: OpenChangeReason) => void

Function to open or close the menu.

snapPoints
SnapPoint[]

The snap points of the drawer.

swipeDirection
SwipeDirection

The swipe direction of the drawer.

snapPoint
SnapPoint | null

The currently active snap point.

setSnapPoint
(snapPoint: SnapPoint | null) => void

Function to set the active snap point.

getOpenPercentage
() => number

Get the current open percentage of the drawer.

getSnapPointIndex
() => number

Get the index of the currently active snap point.

getContentSize
() => number | null

Get the current main-axis size of the drawer content.

getPositionerState
() => PositionerState

Returns the state of the positioner

getContentState
() => ContentState

Returns the state of the content

getTriggerState
(props?: TriggerProps) => TriggerState

Returns the state of a specific trigger, including whether it's the currently active one

getBackdropState
() => BackdropState

Returns the state of the backdrop

getSwipeAreaState
(props?: SwipeAreaProps) => SwipeAreaState

Returns the state of the swipe area

Accessibility

Complies with the Dialog WAI-ARIA design pattern.

KeyDescription
Enter
When focus is on the trigger, opens the dialog.
Tab
Moves focus to the next focusable element within the content. Focus is trapped within the dialog.
Shift + Tab
Moves focus to the previous focusable element. Focus is trapped within the dialog.
Esc
Closes the dialog and moves focus to trigger or the defined final focus element