Confirmation dialog for destructive or high-stakes actions.
npx shadcn@latest add @iconiq/r-alert-dialog"use client";
import { useState } from "react";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogTitle,
AlertDialogTrigger,
alertDialogTriggerSmClassName,
} from "@/components/ui/r-alert-dialog";
export function AlertDialogPreview() {
const [open, setOpen] = useState(false);
return (
<AlertDialog onOpenChange={setOpen} open={open}>
<AlertDialogTrigger asChild>
<button className={alertDialogTriggerSmClassName} type="button">
Delete
</button>
</AlertDialogTrigger>
<AlertDialogContent open={open}>
<AlertDialogHeader>
<AlertDialogTitle>Delete this item?</AlertDialogTitle>
<AlertDialogDescription>
This action permanently removes the item from your workspace. You will not be able to recover it later.
</AlertDialogDescription>
</AlertDialogHeader>
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction>
Delete
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
);
}openControlled open state for the root. Pair with onOpenChange when async actions or parent state should own dismissal.
Type boolean
defaultOpenInitial uncontrolled open state. Ignored when open is provided.
Type boolean·Default false
onOpenChangeCalled when the alert dialog opens or closes through the trigger, cancel action, confirm action, Escape, or controlled state updates.
Type (open: boolean) => void
AlertDialogTriggerOpens the dialog. Use asChild to wrap an existing button, link-styled button, or inline control while preserving trigger behavior.
Type ButtonHTMLAttributes<HTMLButtonElement> & { asChild?: boolean }
AlertDialogContentAnimated card surface. Pass open in controlled usage to keep exit animations synchronized with the root state.
Type Primitive content props & { open?: boolean }
AlertDialogMediaOptional leading icon or media container for warning, publish, or verification visuals.
Type HTMLAttributes<HTMLDivElement>
AlertDialogHeader / AlertDialogFooterLayout slots for title/description copy and the cancel/action row. Mobile order keeps Cancel before the confirming action.
Type HTMLAttributes<HTMLDivElement>
AlertDialogTitle / AlertDialogDescriptionAccessible heading and supporting copy linked by the underlying alert-dialog primitive.
Type Primitive title and description props
AlertDialogAction.variantControls whether the confirming action uses the destructive color treatment or the neutral primary action treatment.
Type "destructive" | "default"·Default "destructive"
AlertDialogAction.closeOnClickSet to false for async requests, keep the root controlled, and close the dialog after the request succeeds.
Type boolean·Default true
AlertDialogCancel.closeOnClickSet to false only when a cancel button needs to run custom validation before closing.
Type boolean·Default true
AlertDialogAction / AlertDialogCancel asChildBase UI and Radix UI installs both support slotted action controls for custom button components.
Type boolean
alertDialogTriggerClassNameDefault trigger recipe for full-size confirmation buttons.
Type string
alertDialogTriggerSmClassNameCompact trigger recipe for inline sentence controls and toolbar-sized buttons.
Type string
alertDialogActionClassName / alertDialogDefaultActionClassName / alertDialogCancelClassNameAction recipes exported for custom footer compositions.
Type string
alertDialogThemeClassNameTheme variable wrapper used by triggers and content, useful when composing custom alert-dialog surfaces.
Type string
AlertDialogPortalPortal primitive export for advanced consumers that need direct portal composition.
Type Primitive Portal
Install the exact registry entry shown on the right when you want the component file and its declared runtime dependencies together.
Dependencies: @base-ui/react, @radix-ui/react-slot, motion.
Install the exact registry entry shown on the right when you want the component file and its declared runtime dependencies together.
Dependencies: @radix-ui/react-alert-dialog, motion.
Contact
Additionally, if you find any bug or issue, feel free to raise an issue.