Implementation guide

Confirm a dangerous delete action in React

Replace a vague “Are you sure?” dialog with a typed confirmation that makes the target and consequence explicit before deletion.

By Tushar Khadde · Published · Updated

The mistake this stops

A destructive action is approved on autopilot because the dialog hides what will be deleted.

A deliberate confirmation step that states the exact action while preserving keyboard and screen-reader access.

Read the Type to Confirm component docs for its live preview, API, accessibility notes, dependencies, and limitations.

React example: Type to Confirm

Install the component, connect it to the action in your app, and keep the server responsible for validating and authorizing the request.

type-to-confirm.tsx
import * as React from "react"
import { TypeToConfirm } from "@/components/ui/type-to-confirm"

export function DeleteRepository() {
  const [open, setOpen] = React.useState(false)

  return (
    <>
      <button type="button" onClick={() => setOpen(true)}>Delete repository</button>
      <TypeToConfirm
        open={open}
        onOpenChange={setOpen}
        phrase="acme/website"
        description="Permanently deletes this repository and its issues."
        onConfirm={() => deleteRepository("acme/website")}
      />
    </>
  )
}

Install the component

pnpm dlx shadcn@latest add @bollard/type-to-confirm

Use it safely

  1. Install the confirmation component near the destructive action.
  2. Require the person to type a meaningful target or phrase before enabling deletion.
  3. Authorize and execute deletion on the server only after confirming the caller and target.