# AlertDialog Interrupt a workflow when someone needs to acknowledge a notice or make a decision before continuing. [Interactive guide](/docs/components/alert-dialog) · Forge 3.2.0 Use the API for your installed version. Run `npx --no-install wss3-forge api --json` inside the project. ## Implementation guidance ### When to use it Use AlertDialog when the user must explicitly acknowledge an important message or make a consequential decision. ### How to compose it Name the affected object and consequence. Put one Cancel and the confirming action in the footer. For asynchronous work, keep the prompt open until success. ### What to verify Confirm initial focus goes to Cancel for a decision. Test Escape, the backdrop, a pending confirmation and a failed confirmation before testing success. ## Usage ```tsx import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogMedia, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, AlertDialogAction } from 'wss3-forge' ``` - Use one AlertDialogCancel per decision. Initial focus goes to Cancel, Tab stays inside the dialog, and Escape returns focus to the opener. Clicking the backdrop keeps a composed decision open. - For an irreversible decision, set destructive on AlertDialogContent, or on AlertDialog inside a React Aria AlertDialogTrigger. Forge adds a warning icon beside the title and applies the danger Button variant to the confirming action, with a white label on a solid danger fill. State what will be lost in AlertDialogDescription. - Place Cancel and the confirming action in AlertDialogFooter. Its transparent surface and top divider separate the actions from the message. Label the confirmation with the action and its object, such as Delete account or Revoke access. - Text-only headers align with the reading direction at every size. Use size="sm" for short prompts. Add AlertDialogMedia when an icon or image helps identify the affected item. The header centers its text when the media sits above it. Give informative images alternative text. - The sm, md and lg presets are 20rem, 24rem and 36rem wide and shrink to fit the viewport. Medium is the default. For a custom width, pass pixels as a number or a CSS length such as min(36rem, 90vw). - The default slide entrance moves the dialog up into place. With entrance="expressive", the destructive icon or your AlertDialogMedia rises into the center and pauses. The panel then expands around it as it settles into the header. With a plain text header, expressive falls back to slide. Use entrance="none" for instant opening. Reduced motion opens the dialog immediately. - Set entrance, size and width on AlertDialogContent, or on AlertDialog in the React Aria trigger composition. - Set open and onOpenChange on AlertDialog to control the decision externally. AlertDialogAction closes after its click handler. Call event.preventDefault() to keep the prompt open while an operation runs, then update open when it succeeds. - The Acknowledgement and Async confirmation examples use the shared AlertDialog preset from wss3-forge across all three library selections. Supply title and buttonText for an acknowledgement. For a decision, pass title and onConfirm. The preset composes the standard AlertDialog header, description and footer with one Cancel action. Set loading while the request runs and close on success. ```tsx Archive draft Archive this draft? You can restore it from the archive. Cancel Archive ``` ## Runnable examples ### Account deletion ```tsx import { useState, type ReactNode } from 'react' import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogTitle, AlertDialogTrigger, Text, VStack } from 'wss3-forge' function DecisionDemo({ trigger, title, description, action, cancel = 'Cancel', media, size, width, entrance, destructive = false, rtl = false, result }: { trigger: string title: string description: string action: string cancel?: string media?: ReactNode size?: 'sm' | 'md' | 'lg' width?: number | string entrance?: 'slide' | 'expressive' | 'none' destructive?: boolean rtl?: boolean result: string }) { const [confirmed, setConfirmed] = useState(false) return ( setConfirmed(false)}> {trigger} {media && {media}} {title} {description} {cancel} setConfirmed(true)}>{action} {confirmed && {result}} ) } function AccountDecision() { return } export default function Example() { return () } ``` ### Basic ```tsx import { useState, type ReactNode } from 'react' import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogTitle, AlertDialogTrigger, Text, VStack } from 'wss3-forge' function DecisionDemo({ trigger, title, description, action, cancel = 'Cancel', media, size, width, entrance, destructive = false, rtl = false, result }: { trigger: string title: string description: string action: string cancel?: string media?: ReactNode size?: 'sm' | 'md' | 'lg' width?: number | string entrance?: 'slide' | 'expressive' | 'none' destructive?: boolean rtl?: boolean result: string }) { const [confirmed, setConfirmed] = useState(false) return ( setConfirmed(false)}> {trigger} {media && {media}} {title} {description} {cancel} setConfirmed(true)}>{action} {confirmed && {result}} ) } function AccountDecision() { return } export default function Example() { return () } ``` ### Small ```tsx import { useState, type ReactNode } from 'react' import { Bluetooth24Regular } from '@fluentui/react-icons' import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogMedia, AlertDialogTitle, AlertDialogTrigger, Text, VStack } from 'wss3-forge' function DecisionDemo({ trigger, title, description, action, cancel = 'Cancel', media, size, width, entrance, destructive = false, rtl = false, result }: { trigger: string title: string description: string action: string cancel?: string media?: ReactNode size?: 'sm' | 'md' | 'lg' width?: number | string entrance?: 'slide' | 'expressive' | 'none' destructive?: boolean rtl?: boolean result: string }) { const [confirmed, setConfirmed] = useState(false) return ( setConfirmed(false)}> {trigger} {media && {media}} {title} {description} {cancel} setConfirmed(true)}>{action} {confirmed && {result}} ) } function AccessoryDecision({ media = false }: { media?: boolean }) { return