Skip to content
Alea0.1

Overlays

Dialog

A focused task on top of the page. AlertDialog confirms something that can't be undone.

Ant Design: Modal

import { DialogTrigger, DialogModal, Dialog, AlertDialog } from '@alea/ui';

Examples

Dialog

A title, a description, content and a footer. Escape and the X close it.

AlertDialog

Confirms what can't be undone. Escape and outside clicks don't close it by accident.

Sizes

sm, md (default), lg and full.

Props

Dialog props

The dialog content: title, text, body and footer. Put it inside DialogModal.

PropTypeDefaultDescription
descriptionReactNode-Text under the title.
footerReactNode | ((opts: { close: () => void; }) => ReactNode)-Buttons at the bottom, e.g. Cancel and Save. Receives close.
hideCloseboolean-Hides the X button.
titleReactNode-The title (required for screen readers unless aria-label is set).

DialogModal props

The modal layer: dims the page, traps focus, closes on Escape (and outside click when isDismissable).

PropTypeDefaultDescription
size"sm" | "md" | "lg" | "full"'md'sm 400, md 520, lg 720, full.

AlertDialog props

A confirm dialog (role alertdialog): Escape and outside click don't dismiss it by accident.

PropTypeDefaultDescription
titlerequiredReactNode-The question, e.g. "Delete this file?".
cancelLabelReactNode'Cancel'The cancel button text. Default "Cancel".
confirmLabelReactNode'Confirm'The confirm button text.
defaultOpenboolean-Open on first render (uncontrolled).
isOpenboolean-Open state (controlled).
onConfirm(() => unknown)-Runs on confirm; the dialog closes after it (awaits a promise).
onOpenChange((open: boolean) => void)-Called when it opens or closes.
tone"danger" | "default"'default'danger turns the confirm button red.

Accessibility

  • Focus moves into the dialog and stays there; it goes back to the trigger on close.
  • The page behind is hidden from screen readers.
  • Escape closes a Dialog; an AlertDialog needs a choice.

Keyboard

KeyDoes
TabCycles inside the dialog
EscapeCloses (not AlertDialog)

Do and don't

Do

  • Give every dialog a title.
  • Put the main action last in the footer.

Don't

  • Don't open a dialog on page load.
  • Don't stack dialogs.

In Figma

Dialog with Size and slots for body and footer.

Tested with axe, keyboard and screen reader roles