Skip to content

Prompt Dialog

Ask for a value (required; Enter confirms).
Type-to-confirm gate (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.

  • 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 PromptDialog from "@invisible-ui/svelte/PromptDialog.svelte";
</script>

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)}
/>
PropTypeDefaultDescription
openbooleanfalseInitial open state.
title *string—Accessible title (required).
descriptionstring | undefinedundefinedOptional supporting message shown under the title.
label *string—Visible label for the input.
valuestring""Initial / current value.
placeholderstring""
requiredbooleanfalseRequire a non-empty value: the confirm button stays disabled while blank.
confirmValuestring | undefinedundefinedType-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.
confirmLabelstring | undefinedundefined
cancelLabelstring | undefinedundefined
confirmVariantButtonVariant"primary"Variant of the confirm button ("danger" for a destructive confirm).
urgentbooleanfalseInterrupting urgency: switches the panel to role="alertdialog", which screen readers announce immediately. Nothing else changes (ADR 0005).
triggerVariantButtonVariant"default"
onConfirm((value: string) => void) | undefinedundefinedCalled with the entered value when confirmed (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; the input is labelled by label and receives focus on open. Escape and a backdrop press cancel.
  • Focus is trapped in the panel and returns to the trigger on close.
<!-- 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-*.