Skip to content
HomeCobalt

Alert dialog

Asks you to confirm before continuing, usually before a delete.

Examples

Asks before deleting, holds while pending, then confirms.

Variants

SmallA yes or no with one line of consequence; text centred at every width, the two actions side by side in a 2 column grid.

Usage

Use it when

  • An action removes, overwrites or sends something that cannot be taken back, and you must confirm first.
  • Leaving a form would lose what was typed.

Use something else when

  • The task has a form or more than one decision. Use Dialog instead.
  • The action can be undone afterwards. Use Toaster with an undo action instead, and skip the question.
  • The choice is between two equal paths, not a confirm. Use Dialog instead.
  • The removal is one row in a menu that needs no confirm. Use a variant="destructive" row in DropdownMenu instead.

Rules

General

Content

Avoid

Limits

Install

npx shadcn@latest add https://kaanarici.com/r/cobalt/alert-dialog.json
import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogError, AlertDialogCancel, AlertDialogAction } from "@/components/cobalt/ui/alert-dialog"