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
Basic
Outside buttons
On compact width the dismiss button and outsideButtons sit above the card.
Accessibility
- Renders
role="dialog"witharia-modal="true", labelled bytitleand described bydescription. - 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;
preventCloseblocks all of them. ModalDismissButtonandModalOutsideButtonare 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.
| Prop | Type | Default | Description |
|---|---|---|---|
| actions | ReactNode | — | Buttons at the bottom, stacked full width. |
| className | string | — | |
| closeLabel | string | Close | |
| description | ReactNode | — | Describes the dialog (`aria-describedby`). |
| disableAnimation | boolean | — | |
| disableOverlay | boolean | — | |
| dismissButtonMode | "none" | "inside" | "outside" | outside | Where the close button goes. `outside` (above the card) applies on compact width only; regular width always places it inside. |
| icon | ReactNode | — | |
| onClose | ((reason: ModalCloseReason) => void) | — | |
| onClosed | (() => void) | — | |
| onOpenChange | ((open: boolean) => void) | — | |
| onOpened | (() => void) | — | |
| open | boolean | false | |
| outsideButtons | ReactNode | — | Extra round buttons beside the dismiss button on compact width. |
| preventClose | boolean | — | Block Escape, overlay click, swipe-down and hide the close button. |
| restoreFocus | RestoreFocus | true | |
| size | string | number | — | Max width on regular width (CSS length). |
| title | ReactNode | — | Labels the dialog. |
| titleAs | ElementType<any, keyof IntrinsicElements> | h2 |
ModalDismissButton
Round XIcon button that closes a modal. ModalPage and ModalCard render it for you.
| Prop | Type | Default | Description |
|---|---|---|---|
| as | ElementType<any, keyof IntrinsicElements> | — | Element to render. Defaults to `a` with `href`, `button` with `onClick`, otherwise `div`. |
| children | string | Close | Accessible label. |
| className | string | — | |
| disabled | boolean | — | |
| href | string | — | |
| rel | string | — | |
| target | string | — | |
| type | "button" | "submit" | "reset" | — |
ModalOutsideButton
Round icon button that sits outside a modal sheet, next to its dismiss button. Renders a link with `href`.
| Prop | Type | Default | Description |
|---|---|---|---|
| aria-label (required) | string | — | Accessible name; the button shows only an icon. |
| children (required) | ReactNode | — | The icon (`size-icon-md`). |
| as | ElementType<any, keyof IntrinsicElements> | — | Element to render. Defaults to `a` with `href`, `button` with `onClick`, otherwise `div`. |
| className | string | — | |
| disabled | boolean | — | |
| href | string | — | |
| rel | string | — | |
| target | string | — | |
| type | "button" | "submit" | "reset" | — |