datui
Color scheme

Overlays

ModalCard

Small modal for one message or decision: icon, title, description and actions. A centered card on regular width, docked to the bottom on compact width.

import { ModalCard, ModalDismissButton, ModalOutsideButton } from "datui";

Examples

On compact width the dismiss button and outsideButtons sit above the card.

Accessibility

  • Renders role="dialog" with aria-modal="true", labelled by title and described by description.
  • Focus moves in on open, is trapped while open and returns to the previously focused element on close.
  • Escape, an overlay click, the dismiss button and (compact) a swipe down close it; preventClose blocks all of them.
  • ModalDismissButton and ModalOutsideButton are icon buttons with an accessible name; outside buttons stay inside the dialog, so they are in the focus trap.

API

ModalCard

Small modal for one message or decision. A centered card on regular width, a card docked to the bottom on compact.

PropTypeDefaultDescription
actionsReactNode—Buttons at the bottom, stacked full width.
classNamestring—
closeLabelstringClose
descriptionReactNode—Describes the dialog (`aria-describedby`).
disableAnimationboolean—
disableOverlayboolean—
dismissButtonMode"none" | "inside" | "outside"outsideWhere the close button goes. `outside` (above the card) applies on compact width only; regular width always places it inside.
iconReactNode—
onClose((reason: ModalCloseReason) => void)—
onClosed(() => void)—
onOpenChange((open: boolean) => void)—
onOpened(() => void)—
openbooleanfalse
outsideButtonsReactNode—Extra round buttons beside the dismiss button on compact width.
preventCloseboolean—Block Escape, overlay click, swipe-down and hide the close button.
restoreFocusRestoreFocustrue
sizestring | number—Max width on regular width (CSS length).
titleReactNode—Labels the dialog.
titleAsElementType<any, keyof IntrinsicElements>h2

ModalDismissButton

Round XIcon button that closes a modal. ModalPage and ModalCard render it for you.

PropTypeDefaultDescription
asElementType<any, keyof IntrinsicElements>—Element to render. Defaults to `a` with `href`, `button` with `onClick`, otherwise `div`.
childrenstringCloseAccessible label.
classNamestring—
disabledboolean—
hrefstring—
relstring—
targetstring—
type"button" | "submit" | "reset"—

ModalOutsideButton

Round icon button that sits outside a modal sheet, next to its dismiss button. Renders a link with `href`.

PropTypeDefaultDescription
aria-label (required)string—Accessible name; the button shows only an icon.
children (required)ReactNode—The icon (`size-icon-md`).
asElementType<any, keyof IntrinsicElements>—Element to render. Defaults to `a` with `href`, `button` with `onClick`, otherwise `div`.
classNamestring—
disabledboolean—
hrefstring—
relstring—
targetstring—
type"button" | "submit" | "reset"—