Skip to content

shadcn.io is an independent project built on shadcn/ui

Free

Simple Delete Confirmation Alert Dialog for React

A delete confirmation titled Delete Item, with a destructive trigger and a destructive Delete action. The item is not removed.

The title is Delete Item. The trigger and the Delete action are both destructive. The text says the item would be permanently deleted. The item stays.

Use the destructive color only when the delete cannot be undone. Say delete, not archive, if you mean delete. Archive can be a normal Dialog. In React, Base UI does not remove the item.

Preview

Preview width

Installation

Sign in to get your install command
Free with an account. It carries your token, so the CLI installs everything in one go.
Use email insteadNo credit card

Anatomy

Alert Dialog anatomy: content, title, description, cancel, action

Usage

<AlertDialog>
  <AlertDialogTrigger render={<Button variant="destructive" />}>
    Delete
  </AlertDialogTrigger>
  <AlertDialogContent>
    <AlertDialogHeader>
      <AlertDialogTitle>Delete Item?</AlertDialogTitle>
      <AlertDialogDescription>
        This action cannot be undone. This will permanently delete the item
        from your account.
      </AlertDialogDescription>
    </AlertDialogHeader>
    <AlertDialogFooter>
      <AlertDialogCancel>Cancel</AlertDialogCancel>
      <AlertDialogAction variant="destructive">Delete</AlertDialogAction>
    </AlertDialogFooter>
  </AlertDialogContent>
</AlertDialog>

FAQ

Why the destructive color?

It's widely read as danger and makes people pause. Use variant="destructive" only for irreversible actions so the signal keeps its meaning.

Should reversible actions use it too?

No. For archive, hide or disable, use a normal confirmation with the default or outline buttons.

Does the trigger need to be destructive too?

It tells people the feature is dangerous before the dialog opens. For lower-stakes deletions an outline trigger with a destructive action works.

How should I word a delete confirmation?

Be specific and plain: This action cannot be undone, and name what is deleted. Don't say remove or archive if you mean delete.

Is it accessible?

Yes. The dialog is an alertdialog labelled by its title and description, and the word Delete on the button carries the meaning without the color.

Does Delete close the dialog?

Yes; run the deletion in its click handler. On Base UI, AlertDialogAction is a plain button that leaves the dialog open: control open and set it to false in the action's handler.

API Reference

Alert Dialog

Sets variant="destructive". The rest is on the Alert Dialog page.

Button

Sets variant="destructive". The rest is on the Button page.