Duolith docs

AlertDialog

Asks the person to confirm or cancel an action, such as deleting, with a destructive variant for actions that cannot be undone.

Stability: experimental

Props

PropTypeDefaultMeans
titlestringThe question, as the heading and the accessible name.
messagestringWhat will happen; the dialog is described by it.
confirmLabelstringConfirmThe confirm button's label, such as Delete.
cancelLabelstringCancelThe cancel button's label.
destructivebooleanfalseShows the confirm button in the danger colour.
openbooleanbindable(false)Whether the dialog shows. Bind it with bind:open={name}; it clears itself when either button is pressed.
onConfirm() => voidRuns when the confirm button is pressed.
onCancel() => voidRuns when the cancel button is pressed or Escape is pressed.

Pieces

PieceMeans
triggerThe control that opens it. Focus returns to it on close.

States

StateLooks like
openA panel up to 360px wide, centred over the scrim, with Cancel (secondary) then Confirm, end-aligned.
destructiveThe confirm button is a danger Button.
openingThe scrim fades in and the panel grows from 95%, in 160 ms; at once with reduced motion.

Accessibility

rolealertdialog with aria-modal="true", described by its message
nameThe title prop (aria-label).
focusOn open, focus goes to the cancel button, the safe choice. Tab stays inside; the page behind is inert. On close, focus returns to the control that opened it.
keyboardEscape cancels. A press on the backdrop does nothing, so the choice is always deliberate.

Theme tokens

color.scrim color.surface color.ink color.muted color.primary color.danger shadow.lg radius.lg space.2 space.5 space.6 text.heading text.body

Example

<AlertDialog title="Delete this post?" confirmLabel="Delete" destructive bind:open={confirming} onConfirm={remove} />