Shadcn Alert Dialog
React alert dialog for delete confirms and irreversible choices. Built with TypeScript and Tailwind CSS for Next.js using Base UI — focus trap and a required answer.
An alert dialog stops the page and asks for a yes or no. Use it when the next click deletes data, spends money, or otherwise cannot be undone. If they need to type something, that is a Dialog.
Looking for a neobrutalism version for shadcn?
Same alert dialog, thicker borders. The NeoBrutalism alert dialog is the kit if you want that look.
Usage
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
} from "@/components/ui/alert-dialog"
import { Button } from "@/components/ui/button"<AlertDialog>
<AlertDialogTrigger render={<Button variant="outline" />}>
Remove Accordion
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>Remove accordion.tsx?</AlertDialogTitle>
<AlertDialogDescription>
This deletes components/ui/accordion.tsx. Add it again with npx
shadcn@latest add https://www.shadcn.io/r/accordion.json.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction>Remove</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>Put render={<Button />} on the trigger so the Button is the actual control. AlertDialogTitle is required — screen readers announce it when the overlay opens.
Composition
Basic
Title, description, cancel, continue. Same keyboard model as the first demo.
Small
size="sm" on AlertDialogContent for a short confirm — connect a device, allow a permission.
Media
AlertDialogMedia sits above the title. Use it when the action needs a symbol, not more words.
Small with Media
size="sm" plus AlertDialogMedia. Permission prompts and hardware connects.
Destructive
variant="destructive" on the action, and say what actually disappears. Cancel stays the quiet button.
RTL
Wrap with DirectionProvider and dir="rtl". Footer buttons follow the reading direction.
API
Prop
Type
AlertDialogContent
Prop
Type
AlertDialogAction and AlertDialogCancel take the same variant and size as Button.
Keyboard
| Key | Action |
|---|---|
Space / Enter | Open from the trigger, or fire the focused button |
Escape | Close and return focus to the trigger |
Tab / Shift + Tab | Cycle controls inside the dialog |
Focus stays in the overlay until it closes. Title and description are announced.
Notes
One decision
If they have to type something, that is a Dialog. This overlay is yes or no.
Name the thing you are about to destroy. After it succeeds, a Sonner toast is enough.
With other components
Trigger and footer actions
DialogWhen they need to type
FormConfirm after submit
AlertInline, does not block
SonnerToast after it succeeds
CardFrame around the confirm
Questions
Related
Was this page helpful?
Sign in to leave feedback.
Alert
React alert for success, errors, and inline notices on a page. Built with TypeScript and Tailwind CSS for Next.js using Base UI — role=alert, default and destructive.
Aspect Ratio
React aspect ratio for images and video embeds. Built with TypeScript and Tailwind CSS for Next.js using Base UI — lock 16/9, 1/1, or any width over height.