Duolith docs

Dialog

A modal in the middle of the screen, over a backdrop, with a title, an optional message, a body and actions.

Stability: experimental

Props

PropTypeDefaultMeans
titlestringThe heading, and the dialog's accessible name.
messagestringA line of text under the title.
openbooleanbindable(false)Whether the dialog shows. Bind it with bind:open={name}; the trigger piece sets it, and Escape or a backdrop press clears it.
dismissiblebooleantrueWhether Escape and a backdrop press close it. Without, only its actions do.

Pieces

PieceMeans
triggerThe control that opens the dialog, such as a Button. It is told the dialog is open (aria-expanded) and gets focus back on close.
actionsButtons at the bottom edge, end-aligned, such as Cancel and Save.

Children

The dialog's body, between the title and the actions, such as a form.

States

StateLooks like
closedNot shown. Only the trigger piece shows where the dialog is written.
openingThe backdrop fades in and the panel rises and grows into place, in 180 ms; at once with reduced motion.
openA surface panel up to 420px wide with a large radius and shadow, centred over the scrim; it scrolls when taller than the window.

Accessibility

roledialog with aria-modal="true"
nameThe title prop (aria-label).
focusOn open, focus moves to the first focusable element in the body, else the first action. Tab and Shift+Tab stay inside, wrapping at the ends; the page behind is inert and does not scroll. On close, focus returns to the control that opened it.
keyboardEscape closes it (unless dismissible is false).
notesThe trigger piece's control carries aria-haspopup="dialog", aria-expanded and aria-controls.

Theme tokens

color.scrim color.surface color.ink color.muted shadow.lg radius.lg space.2 space.3 space.4 space.6 text.heading text.body

Example

<Dialog title="Edit name" bind:open={editing}><TextField label="Name" bind:value={name} /><piece name="actions"><Button label="Save" onPress={save} /></piece></Dialog>