Skip to content
shadcn.io

shadcn.io is not affiliated with official shadcn/ui

Shadcn Alert Dialog for React and Tailwind

A modal for critical confirmations and destructive actions.

Installation

bunx --bun shadcn@latest add https://kit.dev/r/alert-dialog.json

Usage

import {
  AlertDialog,
  AlertDialogAction,
  AlertDialogCancel,
  AlertDialogClose,
  AlertDialogContent,
  AlertDialogFooter,
  AlertDialogHeader,
  AlertDialogTrigger,
} from "@/components/ui/alert-dialog";
import { Button } from "@/components/ui/button";
<AlertDialog>
  <AlertDialogTrigger asChild>
    <Button variant="outline">Open</Button>
  </AlertDialogTrigger>
  <AlertDialogContent>
    <AlertDialogHeader
      description="Do you want to allow the USB accessory to connect to this device?"
      title="Allow accessory to connect?"
    />
    <AlertDialogFooter>
      <AlertDialogCancel>Don't allow</AlertDialogCancel>
      <AlertDialogClose asChild>
        <AlertDialogAction>Allow</AlertDialogAction>
      </AlertDialogClose>
    </AlertDialogFooter>
  </AlertDialogContent>
</AlertDialog>

Accessibility

KeyDescription
Enter
Activate the focused control.
Space
Activate the focused control.

Demos

Variant Destructive

API Reference

AlertDialog

PropType
AttributeType

AlertDialogTrigger

PropType
AttributeType

AlertDialogContent

PropType
AttributeType

AlertDialogBody

PropType
AttributeType

AlertDialogHeader

PropType
AttributeType

AlertDialogTitle

PropType
AttributeType

AlertDialogDescription

PropType
AttributeType

AlertDialogClose

PropType
AttributeType

AlertDialogFooter

PropType
AttributeType

AlertDialogAction

PropType

AlertDialogCancel

PropType
AttributeType