Skip to content

Confirm Dialog

Routine confirmation (role="dialog").
Same choice with urgent (role="alertdialog").

A modal to verify or accept before proceeding — the accessible equivalent of window.confirm(), one of the platform’s simple dialogs. Cancel stops the process, confirm proceeds. It reuses the headless dialog and the shared modal adapter (native <dialog> + showModal(): top layer, inert background, scroll lock). The trigger is the children snippet; onConfirm runs when the confirm button is pressed. Focus lands on the safe choice.

Set urgent when the choice must interrupt: the panel switches to role="alertdialog" (screen readers announce it immediately) and nothing else changes — urgency is a modifier, not a different component (the demo above shows both).

It also works stacked on another dialog — the confirm-on-close case: a Confirm Dialog guarding an edit dialog with unsaved changes. The top layer stacks it above, Escape closes only the confirm, and focus returns into the outer dialog (see the family overview).

Buttons name outcomes, not gestures. The classic trap: “Do you want to cancel the order?” with Cancel / OK buttons — “Cancel” reads both as “cancel the order” and “close this dialog”, and a screen-reader user hears the bare label with no layout around it to disambiguate. Name what each choice does instead: Cancel order / Keep order (or, in the example below, Delete file / Keep file). Both labels are overridable; the defaults are the conventional “Confirm”/“Cancel”, and the examples here always name the outcome.

  • Dialog — generic modal for any content; the head of the family.
  • Alert Dialog — an acknowledgement: a message with nothing to cancel (one button).
  • Confirm Dialog — verify or accept before proceeding: cancel stops, confirm proceeds (urgent to interrupt).
  • Prompt Dialog — asks for a single value (optional, required, or gated by confirmValue; urgent to interrupt).
  • Search Dialog — a quick search: search by keyword and pick from a list.
  • Sheet Dialog — a task in an edge-anchored panel (side variant, optional drag-to-dismiss).
<script>
import ConfirmDialog from "@invisible-ui/svelte/ConfirmDialog.svelte";
</script>

In Elements:

<ds-confirm-dialog
heading="Delete file"
description="Do you want to delete “report-q3.pdf”? The file will be permanently deleted."
confirm-label="Delete file"
cancel-label="Keep file"
confirm-variant="danger"
trigger="Delete file"
></ds-confirm-dialog>
<script type="module">
document
.querySelector("ds-confirm-dialog")
.addEventListener("confirm", () => deleteFile());
</script>

urgent switches the panel to role="alertdialog"; close-button adds a close button to the header.

In React, onConfirm runs on the confirm button, and trigger is the trigger’s content:

<ConfirmDialog
title="Delete file"
description="Do you want to delete “report-q3.pdf”? The file will be permanently deleted."
confirmLabel="Delete file"
cancelLabel="Keep file"
confirmVariant="danger"
trigger="Delete file"
onConfirm={() => deleteFile()}
/>
PropTypeDefaultDescription
openbooleanfalseInitial open state.
title *string—Accessible title naming the confirmation (required).
descriptionstring | undefinedundefinedOptional supporting message.
confirmLabelstring | undefinedundefinedLabel of the confirming button. Defaults to the i18n catalog's "Confirm".
cancelLabelstring | undefinedundefinedLabel of the cancelling button (also the Escape action). Defaults to "Cancel".
confirmVariantButtonVariant"primary"Variant of the confirm button ("danger" for a destructive-ish confirm).
urgentbooleanfalseInterrupting urgency: switches the panel to role="alertdialog", which screen readers announce immediately. Nothing else changes (ADR 0005).
triggerVariantButtonVariant"default"Visual variant for the trigger Button.
onConfirm(() => void) | undefinedundefinedCalled when the confirm button is pressed (before the dialog closes).
closeOnOutsideClickbooleantrueWhether pressing the backdrop cancels and closes. Defaults to true.
closeButtonbooleanfalseShow a close button at the trailing end of the header; it closes like Escape.
closeLabelstring | undefinedundefinedAccessible label for the close button. Defaults to the i18n catalog's "Close".
onOpenChange((open: boolean) => void) | undefinedundefinedCalled whenever the open state changes.
iconSnippet | undefinedundefinedLeading feedback icon in the header.
  • role="dialog", aria-modal, named by its title and described by the optional message. Escape and a backdrop press cancel (set closeOnOutsideClick={false} to require an explicit choice).
  • Focus is trapped in the panel and starts on the Cancel button; it returns to the trigger on close.
<ConfirmDialog
title="Delete file"
description="Do you want to delete “report-q3.pdf”? The file will be permanently deleted."
confirmLabel="Delete file"
cancelLabel="Keep file"
confirmVariant="danger"
onConfirm={() => remove()}
>
Delete file
</ConfirmDialog>

Themeable via --ds-dialog-*.