Skip to content
nexubDesign System
v12.7.0

Components · Overlays

Drawer

StableAdded v0.0.1 · updated v5.1.0

Slide-in panel from any edge of the screen.

import { Drawer } from '@nexub/react';
View as Markdown

Playground

Props

direction
TSX
<Drawer.Root open={open} onOpenChange={setOpen}>…</Drawer.Root>

Examples

Default

Bottom sheet

Props

Props
PropTypeDefaultDescription
Drawer.Rootcompound—Root provider that manages open/close state.
Drawer.Triggercompound—Element that opens the drawer.
Drawer.Portalcompound—Portals the overlay and content into the document body.
Drawer.Overlaycompound—Dimmed backdrop rendered behind the drawer.
Drawer.Contentcompound—The drawer panel. Accepts a side prop.
scrollLock'style' | 'class''class' (since 8.0)On Drawer.Root. How page scroll is locked while open. class adds a class from @nexub/themes/base instead of injecting a <style> tag, so it works under a strict CSP (style-src 'self'). Default style.
direction'bottom' | 'top' | 'left' | 'right''bottom'Edge of the screen from which the drawer slides in.
Drawer.Headercompound—Header section of the drawer panel. Sticky on solid panels (5.1): long content scrolls under it.
Drawer.Footercompound—Footer section of the drawer panel. Sticky on solid panels (5.1): actions stay in view while content scrolls.
Drawer.Titlecompound—Accessible title for the drawer.
Drawer.Descriptioncompound—Supporting description text for the drawer.
Drawer.Closecompound—Element that closes the drawer.
Drawer.Content surface'solid' | 'glass''solid'Glass material on Drawer.Content — see Foundations → Materials.
activeSnapPointstring | number—
autoFocusboolean—
childrenReact.ReactNode—
closeThresholdnumber0.25Fraction (0–1) of the drawer that must be dragged away to close it.
containerHTMLElement—
defaultOpenboolean—Opened by default, skips the initial enter animation. Still reacts to open changes.
disablePreventScrollboolean—
dismissiblebooleantrueWhen false, dragging, outside clicks and Escape don't close the drawer.
fadeFromIndexnumber—Index of the snap point from which the overlay fades. Defaults to the last one.
fixedboolean—Only resize (don't move) the drawer when the on-screen keyboard opens.
handleOnlybooleanfalseOnly the Drawer.Handle starts a drag.
modalbooleantrueWhen false, the page behind stays interactive and nothing is locked or trapped.
nestedboolean—
noBodyStylesboolean—When true, vaul sets no styles on body.
onAnimationEnd((open: boolean) => void)—Gets triggered after the open or close animation ends.
onClose(() => void)—
onDrag((event: React.PointerEvent<HTMLDivElement>, percentageDragged: number) => void)—
onOpenChange((open: boolean) => void)—
onRelease((event: React.PointerEvent<HTMLDivElement>, open: boolean) => void)—
openboolean—
preventScrollRestorationboolean—
repositionInputsboolean—Reposition inputs instead of scrolling them into view when the keyboard opens.
scrollLockTimeoutnumber500ms during which the drawer can't be dragged after its content scrolls.
setActiveSnapPoint((snapPoint: number | string) => void)—
setBackgroundColorOnScalebooleantrue
shouldScaleBackgroundboolean—
snapPoints(string | number)[]—Snap points, as fractions of the screen (e.g. [0.4, 1]) or px strings.
snapToSequentialPointbooleanfalseDon't skip snap points on fast swipes.