Behive Tech Registry

Modal

v0.2.0

A `Card` centered in the viewport with a dimmed backdrop that blocks interaction with the rest of the page, 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.modal

A Card centered in the viewport with a dimmed backdrop that blocks interaction with the rest of the page, 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.

For a panel that docks to an edge of the viewport instead — optionally non-blocking — use @behivetech/atoms.drawer.

Usage

Props

PropTypeDefaultDescription
onClose() => void—Called when the modal 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
childrenReactNode—Dialog content
classNamestring—Additional class names

Compositions

Open all 2 →

Properties

Modal props

PropTypeDefaultDescription
children*ReactNode—Dialog content
onClose*() => void—Called when the modal is dismissed (backdrop click, Escape, or the close button)
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, …).