API reference

import { Drawer } from '@monetr/vaul';

The Drawer export is an object that groups every subcomponent.

<Drawer.Root>
  <Drawer.Trigger />
  <Drawer.Portal>
    <Drawer.Overlay />
    <Drawer.Content>
      <Drawer.Handle />
      <Drawer.Title />
      <Drawer.Description />
      <Drawer.Close />
    </Drawer.Content>
  </Drawer.Portal>
</Drawer.Root>

Drawer.Root

The state container. Every other subcomponent must be rendered inside one (or inside Drawer.NestedRoot).

PropTypeDefault
openboolean-
defaultOpenbooleanfalse
onOpenChange(open: boolean) => void-
modalbooleantrue
direction'top' | 'right' | 'bottom' | 'left''bottom'
dismissiblebooleantrue
handleOnlybooleanfalse
shouldScaleBackgroundboolean-
setBackgroundColorOnScalebooleantrue
closeThresholdnumber (0-1)0.25
scrollLockTimeoutnumber (ms)500
fixedbooleanfalse
noBodyStylesbooleanfalse
disablePreventScrollbooleanfalse
repositionInputsbooleantrue when snapPoints set
preventScrollRestorationbooleanfalse
autoFocusboolean-
containerHTMLElement | nulldocument.body
snapPoints(number | string)[]-
activeSnapPointnumber | string | null-
setActiveSnapPoint(value) => void-
fadeFromIndexnumberlast snap
snapToSequentialPointbooleanfalse
onDrag(event, percentageDragged: number) => void-
onRelease(event, open: boolean) => void-
onClose() => void-
onAnimationEnd(open: boolean) => void-

Drawer.NestedRoot

Same props as Drawer.Root. Use when nesting a drawer inside another drawer's content.

Drawer.Trigger

Aliased to DialogPrimitive.Trigger. Accepts asChild to slot into a custom element.

PropTypeDefault
asChildbooleanfalse

Drawer.Portal

Aliased to DialogPrimitive.Portal. Renders children into a portal so the drawer escapes ancestor stacking contexts.

PropTypeDefault
containerHTMLElement | nulldocument.body

Drawer.Overlay

The dimmed scrim behind the drawer. Click-through closes the drawer when dismissible is true.

PropTypeDefault
asChildbooleanfalse

Drawer.Content

The draggable surface. Accepts every standard div prop.

PropTypeDefault
asChildbooleanfalse

Drawer.Handle

A small grab affordance. Cycles through snap points on click when focused.

PropTypeDefault
preventCyclebooleanfalse
aria-labelstring-

Drawer.Close

Aliased to DialogPrimitive.Close.

PropTypeDefault
asChildbooleanfalse

Drawer.Title

Aliased to DialogPrimitive.Title. Required for accessibility. Use a visually hidden style if you do not want it shown.

Drawer.Description

Aliased to DialogPrimitive.Description. Pair with Drawer.Title for a complete a11y description, or pass aria-describedby={undefined} on Drawer.Content to opt out.

DOM attributes

The library writes a handful of attributes you can target from CSS.

AttributeWhereNotes
data-vaul-drawerDrawer.ContentAlways present, the main hook for styling.
data-vaul-drawer-directionDrawer.ContentOne of top, right, bottom, left.
data-vaul-snap-pointsDrawer.Contenttrue when snapPoints is set.
data-stateDrawer.Content/Overlayopen or closed.
data-vaul-drawer-wrapperConsumer-setMarks the element to scale during shouldScaleBackground.
data-vaul-no-dragConsumer-setAdd to any descendant to exclude it from drag handling.