Behive Tech Registry

Drawer

v0.4.0

A `Card` docked to one edge of the viewport as a slide-in panel, built on [Radix `Dialog`](https://www.radix-ui.com/primitives/docs/components/dialog) for focus trapping, Escape-to-close, and outside-click-to-close. It has no opinion on what goes inside the panel — an optional `title` renders a header with a close button, otherwise just the `children` are shown.

pnpm add @behivetech/atoms.drawer

A Card docked to one edge of the viewport as a slide-in panel, built on Radix Dialog for focus trapping, Escape-to-close, and outside-click-to-close. It has no opinion on what goes inside the panel — an optional title renders a header with a close button, otherwise just the children are shown.

placement controls which edge it docks to; backdrop controls whether it blocks the rest of the page or floats alongside content the user can keep interacting with, e.g. an always-visible properties panel. For a centered dialog that always blocks the page, use @behivetech/atoms.modal instead.

Usage

Props

PropTypeDefaultDescription
onClose() => void—Called when the drawer is dismissed (backdrop click, Escape, or the close button) — required
titlestring—Optional header title; omit to render no header and no close button
iconReactNode—Optional icon rendered before the title; ignored if title is omitted
paddingnone | sm | md | lgnoneInternal padding of the panel body — same values as Card's padding prop
headingLevel1 | 2 | 3 | 4 | 5 | 63Which heading tag wraps title — same values as Card's headingLevel prop
placementtop | right | bottom | left—Which edge the panel docks to — required
backdropbooleantrueWhether a dimmed backdrop blocks the page and closes the drawer when clicked
childrenReactNode—Panel content
classNamestring—Additional class names

Compositions

Open all 4 →

Properties

Drawer props

PropTypeDefaultDescription
children*ReactNode—Panel content
onClose*() => void—Called when the drawer is dismissed (backdrop click, Escape, or the close button)
placement*"top" | "right" | "bottom" | "left"—Which edge the panel slides in from
backdropbooleantrueWhether a dimmed backdrop covers the rest of the page, blocks interaction with it, and closes the drawer when clicked — a real modal. Defaults to true. Set false for a non-blocking panel that floats alongside content the user can keep interacting with, e.g. an always-visible properties panel that updates as a different item is selected behind it.
classNamestring—Additional class names to merge with the component root element
headingLevel5 | 1 | 2 | 3 | 4 | 6—Which heading tag wraps `title` — same values as `Card`'s `headingLevel` prop
iconReactNode—Optional icon rendered before the title in the header; ignored if `title` is omitted
padding"sm" | "md" | "lg" | "none"—Internal padding of the panel body — same values as `Card`'s `padding` prop
titlestring—Optional header title; omit to render no header and no close button

Also accepts the native attributes of its root element (className, aria-*, event handlers, …).