datui
Color scheme

Overlays

ModalPage

Modal panel with header, scrollable content and footer. A centered dialog on regular width and a draggable bottom sheet on compact width.

import { ModalPage, ModalPageHeader, ModalPageContent, ModalRoot } from "datui";

Examples

Controlled with open and onClose(reason).

settlingHeight opens the compact sheet at that height; it can be dragged up or swiped down.

Shows one child modal by activeModal id; each child is still an ordinary controlled modal.

Accessibility

  • Renders role="dialog" with aria-modal="true", labelled by the ModalPageHeader title (an h2 by default).
  • Focus moves into the dialog on open, is trapped while open and returns to the previously focused element on close.
  • Escape, an overlay click, the close button and (compact) a swipe down close it; preventClose blocks all of them.
  • Page scroll is locked and content outside the dialog is hidden from assistive technology while it is open.
  • ModalPageContent is a focusable scroll region so keyboard users can scroll long content.

API

ModalPage

Modal panel with header, scrollable content and footer. A centered dialog on regular width and a draggable bottom sheet on compact width.

PropTypeDefaultDescription
classNamestring—
closeLabelstringClose
disableAnimationboolean—
disableOverlayboolean—Keep the overlay transparent (it still blocks the page).
footerReactNode—
headerReactNode—Usually a `ModalPageHeader`; its title labels the dialog.
heightstring | number—Fixed height (CSS length) on regular width.
hideCloseButtonbooleanfalse
onClose((reason: ModalCloseReason) => void)—Called with the reason whenever the modal asks to close.
onClosed(() => void)—Called after the exit animation, once the modal has unmounted.
onOpenChange((open: boolean) => void)—Called with `false` whenever the modal asks to close.
onOpened(() => void)—Called once the modal has mounted.
openbooleanfalse
outsideButtonsReactNode—Extra round buttons shown above the sheet on compact width (see `ModalOutsideButton`).
preventCloseboolean—Block Escape, overlay click, swipe-down and hide the close button.
restoreFocusRestoreFocustrue
settlingHeight25 | 50 | 75 | 100—Initial height of the compact sheet in percent of the viewport. Below 100 the sheet gets two snap points (this height and full height) and can be dragged between them. Unset, the sheet fits its content.
sizestring | numbersMax width on regular width: a preset or any CSS length.

ModalPageHeader

Title bar of a `ModalPage`. The title becomes the dialog's accessible name.

PropTypeDefaultDescription
afterReactNode—Content at the end, e.g. an action button.
beforeReactNode—Content at the start, e.g. a back button.
classNamestring—
noSeparatorbooleanfalse
titleAsElementType<any, keyof IntrinsicElements>h2Element for the title; it labels the dialog.

ModalPageContent

Scrollable body of a `ModalPage`. It is focusable so keyboard users can scroll it; on compact width the sheet only starts dragging when this area is scrolled to the top.

PropTypeDefaultDescription
classNamestring—

ModalRoot

Shows one of its child modals by id. Each child is an ordinary controlled modal; ModalRoot only sets its `open` and forwards `onClose`, so a plain `open` state per modal works just as well.

PropTypeDefaultDescription
activeModalstringnull`id` of the child modal to show; `null` shows none.
childrenReactNode—`ModalPage` / `ModalCard` elements, each with a unique `id`.
onClose((id: string, reason: ModalCloseReason) => void)—Called with the active modal's id when it asks to close.