Make your AI a shadcn expert

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.

Scroll to load preview...

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

AlertDialogTrigger
AlertDialogMedia
AlertDialogTitle
AlertDialogDescription

Basic

Title, description, cancel, continue. Same keyboard model as the first demo.

Scroll to load preview...

Small

size="sm" on AlertDialogContent for a short confirm — connect a device, allow a permission.

Scroll to load preview...

Media

AlertDialogMedia sits above the title. Use it when the action needs a symbol, not more words.

Scroll to load preview...

Small with Media

size="sm" plus AlertDialogMedia. Permission prompts and hardware connects.

Scroll to load preview...

Destructive

variant="destructive" on the action, and say what actually disappears. Cancel stays the quiet button.

Scroll to load preview...

RTL

Wrap with DirectionProvider and dir="rtl". Footer buttons follow the reading direction.

Scroll to load preview...

API

Prop

Type

AlertDialogContent

Prop

Type

AlertDialogAction and AlertDialogCancel take the same variant and size as Button.

Keyboard

KeyAction
Space / EnterOpen from the trigger, or fire the focused button
EscapeClose and return focus to the trigger
Tab / Shift + TabCycle 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

Questions

Was this page helpful?

Sign in to leave feedback.