Skip to main content

Confirm dialog

Confirms a destructive action, optionally by typing its name.

Guidance​

Confirm dialogs stop a destructive or irreversible action until the person agrees to it. The heading states the consequence as a question ("Delete orders_daily?"), the body says exactly what is destroyed (lineage edges, owners, documentation) and what is not, and the confirm button is crimson with an icon and a word naming what is destroyed ("Delete asset"), so it can never be mistaken for the primary. Cancel is the secondary button and receives focus first, so Enter never destroys anything by accident.

With confirm-text, a mono field labelled "Type orders_daily to confirm" appears and the confirm button stays disabled until the field matches exactly (case and spaces included). Enter in the field confirms once it matches. Use it for deletions that cannot be undone and reach other people's work.

tone="default" uses the primary button for confirmations that are not destructive.

For one-off confirmations, await MmConfirmDialog.confirm({ heading, body, confirmLabel, confirmText }) creates the dialog, shows it, resolves true on confirm and false on cancel or Escape, and removes it afterwards. Focus returns to the element that was focused when it opened. It is announced as an alertdialog, named by the heading and described by the body. Pattern: https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/

Properties​

PropertyAttributeTypeDefaultDescription
headingheadingstring''States the consequence as a question: "Delete orders_daily?".
bodybodystring''What is destroyed or changed. Use the default slot for richer content.
confirmLabelconfirm-labelstring''Verb and object naming what is destroyed: "Delete asset". Defaults to the confirm string.
confirmIconconfirm-iconstring''Icon on the confirm button. Defaults to delete when tone is danger.
cancelLabelcancel-labelstring''Label of the cancel button. Defaults to the cancel string.
confirmTextconfirm-textstring''Turns on type-to-confirm: the confirm button stays disabled until the field matches this exactly.
tonetone'danger' | 'default''danger'danger (default) or default.
openopenbooleanfalseOpens and closes the dialog. Reflects.
loadingloadingbooleanfalseShows a spinner on the confirm button while the action runs.
returnValuestringThe value the dialog last closed with: confirm, cancel, or empty for Escape and the close button.
confirmablebooleanTrue when type-to-confirm is off or the typed text matches exactly.

Events​

EventDetailDescription
mm-confirmCustomEvent<Record<string, never>>The confirm button was activated. Cancel it to keep the dialog open (for example while the deletion runs with loading), then call close('confirm').
mm-openCustomEvent<Record<string, never>>The dialog opened.
mm-closeCustomEvent<DialogCloseDetail>The dialog closed; returnValue is confirm when confirmed.
mm-request-closeCustomEvent<DialogRequestCloseDetail>Escape or the close button asked to close. Cancelable.

Slots​

SlotDescription
DefaultRich body content, in place of body.

CSS parts​

PartDescription
dialogThe inner mm-dialog.
fieldThe type-to-confirm field.
cancelThe cancel button.
confirmThe confirm button.

Examples​

Every state of mm-confirm-dialog in Storybook, with keyboard and screen reader tests.