Skip to content

Destructive confirm ​

A confirm that stays disabled until the reader types the name of the thing being deleted.

Open in demo
Open in demo

Usage ​

requireMatch is the exact text the reader has to type. The confirm button is disabled until the input matches it character for character, and Enter in the input confirms once it does.

Use it where an accidental press cannot be walked back: deleting a project, closing an account, dropping a database. Where undo exists, an ordinary confirm dialog is enough, and asking someone to type a name for a reversible action only teaches them to type names.

The input is cleared every time the dialog opens, so a match left over from a previous attempt can never arm the button.

Like the plain confirm, it is fully controlled: the buttons emit, and you close it.

Examples ​

Through useConfirm ​

Pass variant: 'destructive' and requireMatch. Both are needed; a destructive variant on its own renders the ordinary dialog in the destructive color.

Through useConfirm, the heading becomes "Are you sure?" and your title moves into the body, so the words naming the target are still the first thing read.

API ​

Source: src/shared/components/feedback/DestructiveConfirm.vue

Props ​

PropTypeDefaultDescription
openbooleanrequiredYou own it.
titlestringrequiredThe heading, drawn in the destructive color.
descriptionstring—The body.
requireMatchstringrequiredThe text the reader has to type. Also the input's placeholder.
confirmLabelstring'confirm.confirm'Defaults to "Confirm".
cancelLabelstring'confirm.cancel'Defaults to "Cancel".

Emits ​

EventPayloadDescription
update:openvalue: booleanfalse on Escape or an overlay press.
confirm—Only fires while the typed text matches.
cancel—The cancel button.

Slots ​

None.

Accessibility ​

  • The instruction above the input is a real <label> bound to it, and the text to type is printed inside that label in bold, so the reader is never guessing what to copy.
  • The confirm button is genuinely disabled rather than only looking it, so a screen reader reports it as unavailable.
  • Enter in the input confirms, which is what someone who has just typed a name expects.
  • autocomplete="off" keeps the browser from offering a previously typed name and turning the safeguard into one click.
  • The title and description carry dir="auto", as on the plain confirm.