Prompt Dialog
required; Enter confirms).confirmValue) with urgent — same choice as Confirm dialog, gated by the input.A modal that asks the user for a single value — the accessible equivalent of
window.prompt(), one of the platform’s simple dialogs: everything
Confirm Dialog has, plus an
input. It reuses the headless dialog and the shared modal adapter (native
<dialog> + showModal(): top layer, inert background, scroll lock). The input is focused on open and Enter confirms.
onConfirm(value) runs with the entered text.
The value is optional by default — context decides: set required to keep
the confirm button disabled while blank, or confirmValue for a
type-to-confirm gate, where the button stays disabled until the input matches
exactly — e.g. typing a file name to confirm its deletion (the second demo
above). Pair the gate with confirmVariant="danger" and urgent for
destructive actions: urgent switches the panel to role="alertdialog"
(announced immediately by screen readers) and changes nothing else.
When to use which dialog
Section titled “When to use which dialog”- 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 (
urgentto interrupt). - Prompt Dialog — asks for a single value
(optional,
required, or gated byconfirmValue;urgentto interrupt). - Search Dialog — a quick search: search by keyword and pick from a list.
- Sheet Dialog — a task in an edge-anchored panel
(
sidevariant, optional drag-to-dismiss).
Import
Section titled “Import”<script> import PromptDialog from "@invisible-ui/svelte/PromptDialog.svelte";</script><script setup> import { PromptDialog } from "@invisible-ui/vue";</script>import { PromptDialog } from "@invisible-ui/react";<script type="module"> import "@invisible-ui/elements/define";</script>
<ds-prompt-dialog></ds-prompt-dialog>In Elements:
<ds-prompt-dialog heading="Delete file" description="Do you want to delete “report-q3.pdf”? The file will be permanently deleted." label="Type the file name to confirm" placeholder="report-q3.pdf" confirm-value="report-q3.pdf" confirm-label="Delete file" cancel-label="Keep file" confirm-variant="danger" urgent trigger="Delete file"></ds-prompt-dialog>
<script type="module"> document .querySelector("ds-prompt-dialog") .addEventListener("confirm", (event) => deleteFile(event.detail.value));</script>The confirm event carries the entered text in detail.value, from the
button or Enter in the input.
In React, onConfirm receives the entered text, from the button or Enter in
the input:
<PromptDialog title="Delete file" label="Type the file name to confirm" confirmValue="report-q3.pdf" confirmLabel="Delete file" cancelLabel="Keep file" confirmVariant="danger" urgent trigger="Delete file" onConfirm={(value) => deleteFile(value)}/>| Prop | Type | Default | Description |
|---|---|---|---|
open | boolean | false | Initial open state. |
title * | string | — | Accessible title (required). |
description | string | undefined | undefined | Optional supporting message shown under the title. |
label * | string | — | Visible label for the input. |
value | string | "" | Initial / current value. |
placeholder | string | "" | |
required | boolean | false | Require a non-empty value: the confirm button stays disabled while blank. |
confirmValue | string | undefined | undefined | Type-to-confirm: when set, the confirm button stays disabled until the input matches this exact value — e.g. typing a file name to confirm its deletion. |
confirmLabel | string | undefined | undefined | |
cancelLabel | string | undefined | undefined | |
confirmVariant | ButtonVariant | "primary" | Variant of the confirm button ("danger" for a destructive confirm). |
urgent | boolean | false | Interrupting urgency: switches the panel to role="alertdialog", which screen readers announce immediately. Nothing else changes (ADR 0005). |
triggerVariant | ButtonVariant | "default" | |
onConfirm | ((value: string) => void) | undefined | undefined | Called with the entered value when confirmed (before the dialog closes). |
closeOnOutsideClick | boolean | true | Whether pressing the backdrop cancels and closes. Defaults to true. |
closeButton | boolean | false | Show a close button at the trailing end of the header; it closes like Escape. |
closeLabel | string | undefined | undefined | Accessible label for the close button. Defaults to the i18n catalog's "Close". |
onOpenChange | ((open: boolean) => void) | undefined | undefined | Called whenever the open state changes. |
icon | Snippet | undefined | undefined | Leading feedback icon in the header. |
| Prop | Type | Default | Description |
|---|---|---|---|
triggerVariant | ButtonVariant | "default" | Visual variant for the trigger Button. |
trigger | string | undefined | The trigger button's label. The trigger slot replaces it with markup. |
open | boolean | false | Initial / controlled open state; bindable with v-model:open. |
title * | string | — | Accessible title (required). |
description | string | undefined | Optional supporting message shown under the title. |
label * | string | — | Visible label for the input. |
value | string | "" | Initial value the input is seeded with on each open. |
placeholder | string | "" | |
required | boolean | false | Require a non-empty value: the confirm button stays disabled while blank. |
confirmValue | string | undefined | Type-to-confirm: when set, the confirm button stays disabled until the input matches this exact value, e.g. typing a file name to confirm its deletion. |
confirmLabel | string | undefined | Label of the confirming button; prefer naming the outcome ("Rename"). |
cancelLabel | string | undefined | Label of the cancelling button (also the Escape action). |
confirmVariant | ButtonVariant | "primary" | Variant of the confirm button ("danger" for a destructive confirm). |
urgent | boolean | false | Interrupting urgency: switches the panel to role="alertdialog", which screen readers announce immediately. Nothing else changes (ADR 0005). |
onConfirm | (value: string) => void | undefined | Called with the entered value when confirmed (before the dialog closes). |
closeOnOutsideClick | boolean | true | Whether pressing the backdrop cancels and closes. Defaults to true. |
closeButton | boolean | false | Show a close button at the trailing end of the header; it closes like Escape. |
closeLabel | string | undefined | Accessible label for the close button. Defaults to the catalog's "Close". |
onOpenChange | (open: boolean) => void | undefined |
| Event | Payload |
|---|---|
update:open | open: boolean |
Slots: icon, trigger.
| Prop | Type | Default | Description |
|---|---|---|---|
triggerVariant | ButtonVariant | "default" | Visual variant for the trigger Button. |
trigger | ReactNode | — | The trigger button's content. Defaults to the catalog's "Open". |
open | boolean | false | Initial / controlled open state. |
title * | string | — | Accessible title (required). |
description | string | — | Optional supporting message shown under the title. |
label * | string | — | Visible label for the input. |
value | string | "" | Initial value the input is seeded with on each open. |
placeholder | string | "" | |
required | boolean | false | Require a non-empty value: the confirm button stays disabled while blank. |
confirmValue | string | — | Type-to-confirm: when set, the confirm button stays disabled until the input matches this exact value, e.g. typing a file name to confirm its deletion. |
confirmLabel | string | — | Label of the confirming button; prefer naming the outcome ("Rename"). |
cancelLabel | string | — | Label of the cancelling button (also the Escape action). |
confirmVariant | ButtonVariant | "primary" | Variant of the confirm button ("danger" for a destructive confirm). |
urgent | boolean | false | Interrupting urgency: switches the panel to role="alertdialog", which screen readers announce immediately. Nothing else changes (ADR 0005). |
onConfirm | (value: string) => void | — | Called with the entered value when confirmed (before the dialog closes). |
closeOnOutsideClick | boolean | true | Whether pressing the backdrop cancels and closes. Defaults to true. |
closeButton | boolean | false | Show a close button at the trailing end of the header; it closes like Escape. |
closeLabel | string | — | Accessible label for the close button. Defaults to the catalog's "Close". |
icon | ReactNode | — | Leading feedback icon in the header. |
onOpenChange | (open: boolean) => void | — | Called whenever the open state changes. |
| Attribute | Reactive | Description |
|---|---|---|
heading * | yes | |
label * | yes | |
description | yes | |
value | — | the initial text |
placeholder | yes | |
required | yes | |
confirm-value | yes | |
confirm-label | yes | "Confirm" by default |
cancel-label | yes | "Cancel" by default |
confirm-variant | yes | primary by default |
urgent | yes | |
trigger | yes | opener text |
trigger-variant | yes | |
open | yes | |
close-button | yes | shows a close button in the header |
close-label | yes | |
no-outside-close | — |
Reactive attributes re-render the element when they change after the first render.
Properties: open (boolean).
Methods: notify(options), dismissNotice(id), clearNotices() (the status area, ADR 0016).
Emits: bubbling open-change CustomEvent with detail.open, and confirm with detail.value when the value is confirmed.
Accessibility
Section titled “Accessibility”role="dialog",aria-modal, named by itstitle; the input is labelled bylabeland receives focus on open. Escape and a backdrop press cancel.- Focus is trapped in the panel and returns to the trigger on close.
Example
Section titled “Example”<!-- Type the file name to enable the destructive Delete. --><PromptDialog urgent title="Delete file" description="Do you want to delete “report-q3.pdf”? The file will be permanently deleted." label="Type the file name to confirm" placeholder="report-q3.pdf" confirmValue="report-q3.pdf" confirmLabel="Delete file" cancelLabel="Keep file" confirmVariant="danger" onConfirm={() => remove()}> Delete file</PromptDialog>Themeable via --ds-dialog-*.