Skip to content
IndexRequest a UIAboutContact

Type-to-Confirm Delete

A destructive dialog where the confirm button unlocks only after you type the exact phrase.

Open alone ↗

AI prompt

PROMPT: PASTE INTO YOUR AI CODING TOOL
Design an alert dialog for deleting a project called "Atlas". Title "Delete project Atlas?", body "This permanently deletes 48 files and cannot be undone." A labelled text input asks the user to type "delete atlas" to confirm; the red "Delete project" button stays disabled until the input matches exactly (case-insensitive). A neutral Cancel button sits to its left. Use role alertdialog with aria-labelledby and aria-describedby, move focus to the input on open, trap Tab inside, close on Escape and return focus to the trigger button. Light backdrop blur, 14 pixel radius, minimal styling, 180 millisecond scale-fade entry with prefers-reduced-motion fallback. Plain HTML, CSS, JavaScript.

About this pattern

Definition

A type-to-confirm dialog adds friction to irreversible actions. The danger button stays disabled until the person types a specific phrase, which prevents accidental clicks.

Purpose & UX principles

  • Use it only for destructive, hard-to-undo actions such as deleting a project; for reversible actions prefer undo.
  • Name what will be lost, state that it cannot be undone and show the exact phrase to type.
  • Focus starts on the input; Escape and Cancel close safely; focus returns to the opener.

Interaction states

  • Closed, open with confirm disabled, open with matching text (confirm enabled), deleted result.

Motion specification

  • Dialog fades and scales from 0.96 over 180ms; backdrop fades over 180ms.
  • Reduced motion: no scale, instant fade.

Responsive behaviour

  • Dialog is up to 360px wide and centred; on phones it fills the width with 16px margins.
  • Buttons stack on very narrow screens, with the safe action first.

Code

HTML
<div class="bx"><button class="trig" id="trig" type="button">Delete project…</button><p class="res" id="res" aria-live="polite">Project "Atlas" is active.</p>
<div class="bk" id="bk" hidden><div class="dlg" id="dlg" role="alertdialog" aria-modal="true" aria-labelledby="t" aria-describedby="d"><h2 id="t">Delete project Atlas?</h2><p id="d">This permanently deletes 48 files and cannot be undone.</p><label><span>Type <b>delete atlas</b> to confirm</span><input id="in" autocomplete="off"></label><div class="bt"><button id="cn" type="button">Cancel</button><button id="ok" type="button" disabled>Delete project</button></div></div></div></div>

Related patterns

Modal Dialog

↗
Modal DialogOverlays & Dialogs

Press Feedback

↗
Press FeedbackButtons & Actions

Validation States

↗
Validation StatesInputs & Forms