structyl

Drawer API

View component

The full prop reference for the Drawer component. A bottom-anchored sheet, ideal for mobile.

Import

tsx
import { Drawer } from '@structyl/styled';

Props

Root

Container component that manages drawer open/closed state. Wraps all other drawer parts.

PropTypeDefault
open#boolean

Controlled state: whether drawer is open

defaultOpen#boolean

Uncontrolled initial state: drawer open on mount

false
onOpenChange#(open: boolean) => void

Callback fired when drawer open state changes

modal#boolean

Whether drawer is modal (disables outside interaction when open)

true
children#React.ReactNode

Drawer content and child parts

Trigger

Button element that toggles drawer open/closed state

PropTypeDefault
asChild#boolean

Render as child element instead of button

className#string

CSS class name

onClick#(e: React.MouseEvent<HTMLButtonElement>) => void

Click event handler

...buttonProps#React.ComponentPropsWithoutRef<'button'>

All standard HTML button attributes (type, aria-*, data-*, etc.)

Portal

Portal component that renders drawer content outside DOM hierarchy

PropTypeDefault
children#React.ReactNode

Portal content (Overlay and Content)

container#Element | DocumentFragment | null

DOM element to portal into (defaults to document.body)

forceMount#boolean

Mount portal contents even when drawer is closed

Overlay

Semi-transparent backdrop behind drawer content

PropTypeDefault
asChild#boolean

Render as child element instead of div

className#string

CSS class name

forceMount#boolean

Mount overlay even when drawer is closed

...divProps#React.ComponentPropsWithoutRef<'div'>

All standard HTML div attributes (style, data-*, aria-*, etc.)

Content

Main drawer container with animations. Positioned at bottom by default.

PropTypeDefault
asChild#boolean

Render as child element instead of div

className#string

CSS class name

forceMount#boolean

Mount content even when drawer is closed

onEscapeKeyDown#(event: KeyboardEvent) => void

Callback when Escape key pressed inside drawer

onPointerDownOutside#(event: PointerDownOutsideEvent) => void

Callback when pointer down outside drawer

onInteractOutside#(event: PointerDownOutsideEvent | FocusOutsideEvent) => void

Callback when any interaction outside drawer occurs

onOpenAutoFocus#(event: Event) => void

Callback to control focus when drawer opens

onCloseAutoFocus#(event: Event) => void

Callback to control focus when drawer closes

...divProps#React.ComponentPropsWithoutRef<'div'>

All standard HTML div attributes (style, data-*, aria-*, etc.)

Header

Container for drawer title and description with default padding and layout

PropTypeDefault
className#string

CSS class name

children#React.ReactNode

Header content

...divProps#React.HTMLAttributes<HTMLDivElement>

All standard HTML div attributes

Title

Drawer title heading element (h2). Associates with aria-labelledby.

PropTypeDefault
asChild#boolean

Render as child element instead of h2

className#string

CSS class name

children#React.ReactNode

Title text

...h2Props#React.ComponentPropsWithoutRef<'h2'>

All standard HTML h2 attributes (id, data-*, aria-*, etc.)

Description

Drawer description/subtitle element (p). Associates with aria-describedby.

PropTypeDefault
asChild#boolean

Render as child element instead of p

className#string

CSS class name

children#React.ReactNode

Description text

...pProps#React.ComponentPropsWithoutRef<'p'>

All standard HTML p attributes (id, data-*, aria-*, etc.)

Close

Button element that closes the drawer

PropTypeDefault
asChild#boolean

Render as child element instead of button

className#string

CSS class name

onClick#(e: React.MouseEvent<HTMLButtonElement>) => void

Click event handler

...buttonProps#React.ComponentPropsWithoutRef<'button'>

All standard HTML button attributes (type, aria-*, data-*, etc.)

Source code

If you didn't find what you need here, read the component implementation .

structyl — Accessible React Component Library