Skip to content

Dialog

A modal dialog on Base UI Dialog: 16px tray radius, scale-in on desktop, a popped card on phones.

For a short task that has to finish or be dismissed before the page goes on. A decision that must not be dismissed by a click outside is an @khaeli/alert-dialog; a create or edit form is a @khaeli/form-dialog.

Default

With a form

Installation

npx shadcn@latest add @khaeli/dialog

Install @khaeli/foundation first: this item's styling lives in its tokens and [data-slot] rules.

Installs with

npm packages
  • @base-ui/react ^1.7.0
  • @keyline-icons/react ^2.2.0

Keyboard

EnterSpace
On the trigger, opens the dialog. Focus moves to the first control inside it: the first field, or the first button when it has no field.
TabShift Tab
Move through the controls inside the dialog and wrap at either end. The close button in the corner comes last. Focus cannot leave the dialog while it is open.
Escape
Closes the dialog and returns focus to the trigger. A click on the dimmed page does the same.

Accessible name

  • The dialog is named by DialogTitle and described by DialogDescription: Base UI wires both with aria-labelledby and aria-describedby. Always render a title.
  • The close button in the corner is named Close by the item. showCloseButton={false} removes it, so keep another way out in the footer: a DialogClose, or DialogFooter showCloseButton.
  • DialogTrigger and DialogClose take your button through render; the name is the button's text.
  • While the dialog is open the rest of the page is hidden from assistive technology with aria-hidden.

Registry JSON

The item as the shadcn CLI reads it, with every file it ships: https://ui.khaeli.com/r/dialog.json