AlertDialog
A modal confirmation dialog that focuses the safe cancel action and prevents outside dismissal.
A modal confirmation dialog for important or destructive actions, with safe initial focus on the cancel button and outside dismissal disabled. The examples on this page use the Shadcn Rhea style preset.
Preview
Section titled “Preview”<wc-shadcn-alert-dialog-root style-profile="rhea">
<wc-shadcn-alert-dialog-trigger
style-profile="rhea"
variant="outline"
>
Show Dialog
</wc-shadcn-alert-dialog-trigger>
<wc-shadcn-alert-dialog-mask
style-profile="rhea"
></wc-shadcn-alert-dialog-mask>
<wc-shadcn-alert-dialog-content style-profile="rhea">
<wc-shadcn-alert-dialog-header style-profile="rhea">
<wc-shadcn-alert-dialog-title style-profile="rhea">
Are you absolutely sure?
</wc-shadcn-alert-dialog-title>
<wc-shadcn-alert-dialog-description style-profile="rhea">
This action cannot be undone. This will permanently delete
your account and remove your data from our servers.
</wc-shadcn-alert-dialog-description>
</wc-shadcn-alert-dialog-header>
<wc-shadcn-alert-dialog-footer style-profile="rhea">
<wc-shadcn-alert-dialog-cancel style-profile="rhea">
Cancel
</wc-shadcn-alert-dialog-cancel>
<wc-shadcn-alert-dialog-action style-profile="rhea">
Continue
</wc-shadcn-alert-dialog-action>
</wc-shadcn-alert-dialog-footer>
</wc-shadcn-alert-dialog-content>
</wc-shadcn-alert-dialog-root>Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases (@proto.ui/prototypes-shadcn; currently available from workspace source).
import { ShadcnAlertDialogRoot, ShadcnAlertDialogTrigger, ShadcnAlertDialogMask, ShadcnAlertDialogContent, ShadcnAlertDialogHeader, ShadcnAlertDialogTitle, ShadcnAlertDialogDescription, ShadcnAlertDialogFooter, ShadcnAlertDialogCancel, ShadcnAlertDialogAction,} from '../proto-ui/components/react';
export function Example() { return ( <ShadcnAlertDialogRoot styleProfile="rhea"> <ShadcnAlertDialogTrigger variant="outline">Show Dialog</ShadcnAlertDialogTrigger> <ShadcnAlertDialogMask /> <ShadcnAlertDialogContent> <ShadcnAlertDialogHeader> <ShadcnAlertDialogTitle>Are you absolutely sure?</ShadcnAlertDialogTitle> <ShadcnAlertDialogDescription> This action cannot be undone. This will permanently delete your account. </ShadcnAlertDialogDescription> </ShadcnAlertDialogHeader> <ShadcnAlertDialogFooter> <ShadcnAlertDialogCancel>Cancel</ShadcnAlertDialogCancel> <ShadcnAlertDialogAction>Continue</ShadcnAlertDialogAction> </ShadcnAlertDialogFooter> </ShadcnAlertDialogContent> </ShadcnAlertDialogRoot> );}Composition
Section titled “Composition”AlertDialogRoot├── AlertDialogTrigger├── AlertDialogMask└── AlertDialogContent ├── AlertDialogHeader │ ├── AlertDialogTitle │ └── AlertDialogDescription └── AlertDialogFooter ├── AlertDialogCancel └── AlertDialogAction- Root: Manages open state with
alertdialogmodality always enabled. - Trigger / Cancel / Action: Each retains its own Base command state and supports
variant,size,wrap, anddisabled. ActivatingActionemitsactionbefore requesting close. - Mask / Content: Provides the modal backdrop, focus trap, and 150ms enter/leave transitions; focuses
Cancelfirst on open and blocks outside-click dismissal. - Style presets (
styleProfile): Supportsvega,nova,maia,lyra,mira,luma,sera,rhea, andnew-york-v4(new-yorkalias). When omitted, parts inherit from the nearest Style Scope.
Keyboard & Accessibility
Section titled “Keyboard & Accessibility”EscapeandCancelrequest dismissal and restore focus to the trigger.Tab/Shift + Tabloops focus strictly withinContent.- Initial focus targets the safe
Cancelbutton by default; disabled commands do not activate.
Examples
Section titled “Examples”Pass size="sm" on Content for a compact confirmation dialog, paired with align="center" on Header.
<wc-shadcn-alert-dialog-root style-profile="rhea">
<wc-shadcn-alert-dialog-trigger
style-profile="rhea"
variant="outline"
>
Show Dialog
</wc-shadcn-alert-dialog-trigger>
<wc-shadcn-alert-dialog-mask
style-profile="rhea"
></wc-shadcn-alert-dialog-mask>
<wc-shadcn-alert-dialog-content style-profile="rhea" size="sm">
<wc-shadcn-alert-dialog-header
style-profile="rhea"
align="center"
>
<wc-shadcn-alert-dialog-title style-profile="rhea">
Allow accessory to connect?
</wc-shadcn-alert-dialog-title>
<wc-shadcn-alert-dialog-description style-profile="rhea">
Do you want to allow the USB accessory to connect to this
device?
</wc-shadcn-alert-dialog-description>
</wc-shadcn-alert-dialog-header>
<wc-shadcn-alert-dialog-footer style-profile="rhea">
<wc-shadcn-alert-dialog-cancel style-profile="rhea">
Don't allow
</wc-shadcn-alert-dialog-cancel>
<wc-shadcn-alert-dialog-action style-profile="rhea">
Allow
</wc-shadcn-alert-dialog-action>
</wc-shadcn-alert-dialog-footer>
</wc-shadcn-alert-dialog-content>
</wc-shadcn-alert-dialog-root>Place an icon badge inside Header to visually anchor the confirmation prompt.
<wc-shadcn-alert-dialog-root style-profile="rhea">
<wc-shadcn-alert-dialog-trigger
style-profile="rhea"
variant="outline"
>
Share Project
</wc-shadcn-alert-dialog-trigger>
<wc-shadcn-alert-dialog-mask
style-profile="rhea"
></wc-shadcn-alert-dialog-mask>
<wc-shadcn-alert-dialog-content style-profile="rhea">
<wc-shadcn-alert-dialog-header
style-profile="rhea"
align="center"
>
<div
class="mb-2 inline-flex size-10 items-center justify-center rounded-lg bg-muted text-foreground"
aria-hidden="true"
>
+
</div>
<wc-shadcn-alert-dialog-title style-profile="rhea">
Share this project?
</wc-shadcn-alert-dialog-title>
<wc-shadcn-alert-dialog-description style-profile="rhea">
Anyone with the link will be able to view and edit this
project.
</wc-shadcn-alert-dialog-description>
</wc-shadcn-alert-dialog-header>
<wc-shadcn-alert-dialog-footer style-profile="rhea">
<wc-shadcn-alert-dialog-cancel style-profile="rhea">
Cancel
</wc-shadcn-alert-dialog-cancel>
<wc-shadcn-alert-dialog-action style-profile="rhea">
Share
</wc-shadcn-alert-dialog-action>
</wc-shadcn-alert-dialog-footer>
</wc-shadcn-alert-dialog-content>
</wc-shadcn-alert-dialog-root>Destructive
Section titled “Destructive”Use variant="destructive" on Trigger and Action with a compact confirmation panel for irreversible actions.
<wc-shadcn-alert-dialog-root style-profile="rhea">
<wc-shadcn-alert-dialog-trigger
style-profile="rhea"
variant="destructive"
>
Delete Chat
</wc-shadcn-alert-dialog-trigger>
<wc-shadcn-alert-dialog-mask
style-profile="rhea"
></wc-shadcn-alert-dialog-mask>
<wc-shadcn-alert-dialog-content style-profile="rhea" size="sm">
<wc-shadcn-alert-dialog-header
style-profile="rhea"
align="center"
>
<div
class="mb-2 inline-flex size-10 items-center justify-center rounded-lg bg-destructive/10 text-destructive"
aria-hidden="true"
>
!
</div>
<wc-shadcn-alert-dialog-title style-profile="rhea">
Delete chat?
</wc-shadcn-alert-dialog-title>
<wc-shadcn-alert-dialog-description style-profile="rhea">
This will permanently delete this chat conversation and
remove any memories saved during this chat.
</wc-shadcn-alert-dialog-description>
</wc-shadcn-alert-dialog-header>
<wc-shadcn-alert-dialog-footer style-profile="rhea">
<wc-shadcn-alert-dialog-cancel
style-profile="rhea"
variant="outline"
>
Cancel
</wc-shadcn-alert-dialog-cancel>
<wc-shadcn-alert-dialog-action
style-profile="rhea"
variant="destructive"
>
Delete
</wc-shadcn-alert-dialog-action>
</wc-shadcn-alert-dialog-footer>
</wc-shadcn-alert-dialog-content>
</wc-shadcn-alert-dialog-root>Controlled
Section titled “Controlled”Pass open and listen to openChange and action so your application owns the dialog visibility and confirmed side effects.
<wc-shadcn-alert-dialog-root
id="controlled-alert"
style-profile="rhea"
>
<wc-shadcn-alert-dialog-trigger
style-profile="rhea"
variant="outline"
>
Archive Workspace
</wc-shadcn-alert-dialog-trigger>
<wc-shadcn-alert-dialog-mask
style-profile="rhea"
></wc-shadcn-alert-dialog-mask>
<wc-shadcn-alert-dialog-content style-profile="rhea">
<wc-shadcn-alert-dialog-header style-profile="rhea">
<wc-shadcn-alert-dialog-title style-profile="rhea">
Archive this workspace?
</wc-shadcn-alert-dialog-title>
<wc-shadcn-alert-dialog-description style-profile="rhea">
Members will keep read-only access until an administrator
restores the workspace.
</wc-shadcn-alert-dialog-description>
</wc-shadcn-alert-dialog-header>
<wc-shadcn-alert-dialog-footer style-profile="rhea">
<wc-shadcn-alert-dialog-cancel style-profile="rhea">
Cancel
</wc-shadcn-alert-dialog-cancel>
<wc-shadcn-alert-dialog-action
id="archive-action"
style-profile="rhea"
>
Archive
</wc-shadcn-alert-dialog-action>
</wc-shadcn-alert-dialog-footer>
</wc-shadcn-alert-dialog-content>
</wc-shadcn-alert-dialog-root>
<script type="module">
import { setElementProps } from '@proto.ui/adapter-web-component';
const root = document.querySelector('#controlled-alert');
setElementProps(root, { open: false });
root.addEventListener('openChange', (e) =>
setElementProps(root, { open: e.detail.open })
);
</script>Set dir="rtl" on the container and dialog content; Header uses logical alignment (text-start) to adapt automatically.
<div dir="rtl" lang="ar" class="flex gap-4">
<wc-shadcn-alert-dialog-root style-profile="rhea">
<wc-shadcn-alert-dialog-trigger
style-profile="rhea"
variant="outline"
>
إظهار الحوار
</wc-shadcn-alert-dialog-trigger>
<wc-shadcn-alert-dialog-mask
style-profile="rhea"
></wc-shadcn-alert-dialog-mask>
<wc-shadcn-alert-dialog-content style-profile="rhea">
<div dir="rtl" lang="ar" class="grid gap-6">
<wc-shadcn-alert-dialog-header style-profile="rhea">
<wc-shadcn-alert-dialog-title style-profile="rhea">
هل أنت متأكد تمامًا؟
</wc-shadcn-alert-dialog-title>
<wc-shadcn-alert-dialog-description style-profile="rhea">
لا يمكن التراجع عن هذا الإجراء. سيؤدي هذا إلى حذف حسابك
نهائيًا من خوادمنا.
</wc-shadcn-alert-dialog-description>
</wc-shadcn-alert-dialog-header>
<wc-shadcn-alert-dialog-footer style-profile="rhea">
<wc-shadcn-alert-dialog-cancel style-profile="rhea">
إلغاء
</wc-shadcn-alert-dialog-cancel>
<wc-shadcn-alert-dialog-action style-profile="rhea">
متابعة
</wc-shadcn-alert-dialog-action>
</wc-shadcn-alert-dialog-footer>
</div>
</wc-shadcn-alert-dialog-content>
</wc-shadcn-alert-dialog-root>
</div>Unlike Dialog, AlertDialog Root always operates in alertdialog mode.
| Prop / Event / Method | Type | Default |
|---|---|---|
open | boolean | undefined (uncontrolled) |
defaultOpen | boolean | false |
disabled | boolean | false |
a11yLabel | string | '' |
styleProfile | ShadcnStyleChoice | inherit → scope → new-york-v4 |
openChange (event) | { open: boolean; reason: string null; focusReason: string null } | — |
openAlertDialog / close / toggle (methods) | (reason?: string) => void | — |
Content & Mask
Section titled “Content & Mask”| Prop | Type | Default |
|---|---|---|
Content.size | 'default' 'sm' | 'default' |
Content.enterDuration / leaveDuration | number | 150 |
Mask.passthrough | boolean | false |
Mask.enterDuration / leaveDuration | number | 150 |
Header.align | 'start' 'center' | 'start' |
Trigger, Cancel & Action
Section titled “Trigger, Cancel & Action”| Prop / Event | Type | Default |
|---|---|---|
variant | 'default' 'destructive' 'outline' 'secondary' 'ghost' 'link' | Trigger/Cancel: 'outline'; Action: 'default' |
size | 'default' 'sm' 'lg' 'icon' | 'default' |
wrap | boolean | false |
disabled | boolean | false |
Action.action (event) | { reason: string } | — |