Feedback & Status

Drawer

A panel with swipe dismissal and optional vertical snap points.

A panel with swipe dismissal and optional vertical snap points.

Bottom drawer#

Side drawer#

Snap points#

Component parts#

ComponentPurpose
DrawerRoot: open, defaultOpen, onOpenChange, swipeDirection, and snap-point props
DrawerTriggerOpens the drawer; use render={<Button />} for Zen button styles
DrawerContentStyled popup with portal, backdrop, viewport, and scrollable content
DrawerTitleAccessible title; include one in every drawer
DrawerDescriptionOptional accessible description
DrawerCloseCloses the drawer; supports render

swipeDirection defaults to down (bottom). Use up for top, left for left, or right for right. Snap points apply to vertical drawers. Set the content height to accommodate the largest snap point.

Component props#

Drawer#

NameTypeDescription
openbooleanControlled open state.
defaultOpenbooleanInitial open state when uncontrolled (default: false).
onOpenChange(open, eventDetails) => voidCalled when the drawer opens or closes. Event details include the reason and a cancel method.
onOpenChangeComplete(open: boolean) => voidCalled after the opening or closing animation completes.
swipeDirection'up' | 'down' | 'left' | 'right'Dismissal direction and edge placement (default: 'down').
modalboolean | 'trap-focus'Controls focus trapping, scroll locking, and outside interaction (default: true). 'trap-focus' traps focus without locking page scrolling.
disablePointerDismissalbooleanPrevents dismissal by outside presses and, for non-modal drawers, focus moving outside (default: false).
snapPoints(number | string)[]Vertical snap positions. Numbers from 0 to 1 represent viewport-height fractions; larger numbers represent pixels. Strings accept px or rem units.
snapPointnumber | string | nullControlled active snap point.
defaultSnapPointnumber | string | nullInitial snap point when uncontrolled.
onSnapPointChange(snapPoint, eventDetails) => voidCalled when the active snap point changes.
snapToSequentialPointsbooleanUses drag distance instead of velocity to choose the next snap point (default: false).
triggerIdstring | nullIdentifies the active trigger when controlling the drawer.
defaultTriggerIdstring | nullIdentifies the trigger for an initially open, uncontrolled drawer.
actionsRefRefObjectReceives imperative close and unmount actions.
handleDrawerHandleAssociates the drawer with detached triggers.
childrenReactNode | functionDrawer parts, or a render function receiving the active trigger payload.

DrawerContent#

NameTypeDescription
childrenReactNodeContent displayed inside the drawer.
classNamestring | (state) => stringAdditional popup classes, optionally based on drawer state.
styleCSSProperties | (state) => CSSPropertiesPopup styles, including width or height.
initialFocusboolean | RefObject | functionControls where focus moves when the drawer opens.
finalFocusboolean | RefObject | functionControls where focus returns when the drawer closes.
portalPropsDrawer.Portal.PropsPortal options, including a custom container and keepMounted.
renderReactElement | functionCustomizes the popup element.

The forwarded ref targets the popup element. Standard div attributes and event handlers are also supported.

DrawerTrigger and DrawerClose#

NameTypeDescription
childrenReactNodeButton content.
renderReactElement | functionCustomizes the button element. The examples use a Zen Button.
disabledbooleanDisables the button (default: false).
nativeButtonbooleanSet to false when render uses a non-button element (default: true).
classNamestring | (state) => stringAdditional button classes.

DrawerTrigger also accepts id to identify the trigger, handle to associate a detached trigger with a drawer, and payload to pass data to the root's render function. Both components support standard button attributes and event handlers.

DrawerTitle and DrawerDescription#

NameTypeDescription
childrenReactNodeTitle or description content.
renderReactElement | functionCustomizes the rendered element.
classNamestring | (state) => stringAdditional element classes.
styleCSSProperties | (state) => CSSPropertiesAdditional element styles.

Include a DrawerTitle to give the drawer an accessible name. DrawerDescription supplies an optional accessible description.