Alert Dialog
---import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogCancel, AlertDialogAction } from "@/components/starwind/alert-dialog";import { Button } from "@/components/starwind/button";---
<AlertDialog> <AlertDialogTrigger asChild> <Button variant="outline">Show Alert Dialog</Button> </AlertDialogTrigger> <AlertDialogContent> <AlertDialogHeader> <AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle> <AlertDialogDescription> This action cannot be undone. This will permanently delete your account and remove your data from our servers. </AlertDialogDescription> </AlertDialogHeader> <AlertDialogFooter> <AlertDialogCancel>Cancel</AlertDialogCancel> <AlertDialogAction>Continue</AlertDialogAction> </AlertDialogFooter> </AlertDialogContent></AlertDialog>import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogCancel, AlertDialogAction } from "@/components/starwind/alert-dialog";import { Button } from "@/components/starwind/button";
export function Example() { return ( <AlertDialog> <AlertDialogTrigger asChild> <Button variant="outline">Show Alert Dialog</Button> </AlertDialogTrigger> <AlertDialogContent> <AlertDialogHeader> <AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle> <AlertDialogDescription> This action cannot be undone. This will permanently delete your account and remove your data from our servers. </AlertDialogDescription> </AlertDialogHeader> <AlertDialogFooter> <AlertDialogCancel>Cancel</AlertDialogCancel> <AlertDialogAction>Continue</AlertDialogAction> </AlertDialogFooter> </AlertDialogContent> </AlertDialog> );}Installation
pnpx starwind@latest add alert-dialognpx starwind@latest add alert-dialogyarn dlx starwind@latest add alert-dialogFramework Availability
Astro Available React AvailableAlert Dialog is available for Astro and React.
Usage
General Notes
Alert dialogs are used to interrupt the user with important information that requires a response. Alert dialogs are modal and should be used sparingly for critical actions like confirmations, warnings, or errors.
The essential components are AlertDialog, AlertDialogTrigger, and AlertDialogContent. The AlertDialogAction and AlertDialogCancel components provide standard button behaviors for user responses.
Destructive Actions
Alert dialogs are commonly used to confirm destructive actions like deleting data.
---import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogCancel, AlertDialogAction } from "@/components/starwind/alert-dialog";import { Button } from "@/components/starwind/button";---
<AlertDialog> <AlertDialogTrigger asChild> <Button variant="error">Delete Account</Button> </AlertDialogTrigger> <AlertDialogContent> <AlertDialogHeader> <AlertDialogTitle>Delete Account</AlertDialogTitle> <AlertDialogDescription> Are you sure you want to delete your account? This action is permanent and cannot be undone. All your data, including projects, settings, and personal information will be permanently removed. </AlertDialogDescription> </AlertDialogHeader> <AlertDialogFooter> <AlertDialogCancel>Cancel</AlertDialogCancel> <AlertDialogAction>Delete Account</AlertDialogAction> </AlertDialogFooter> </AlertDialogContent></AlertDialog>Custom Styling
You can customize the appearance of alert dialog components using the class prop.
---import { AlertDialog, AlertDialogTrigger, AlertDialogContent, AlertDialogHeader, AlertDialogFooter, AlertDialogTitle, AlertDialogDescription, AlertDialogCancel, AlertDialogAction } from "@/components/starwind/alert-dialog";import { Button } from "@/components/starwind/button";---
<AlertDialog> <AlertDialogTrigger asChild> <Button variant="outline">Custom Alert</Button> </AlertDialogTrigger> <AlertDialogContent class="sm:max-w-md"> <AlertDialogHeader> <AlertDialogTitle class="text-center">Custom Alert Dialog</AlertDialogTitle> <AlertDialogDescription class="text-center"> This alert dialog has custom styling applied to make it more compact and centered. </AlertDialogDescription> </AlertDialogHeader> <AlertDialogFooter class="sm:justify-center"> <AlertDialogCancel class="w-full sm:w-auto">Cancel</AlertDialogCancel> <AlertDialogAction class="w-full sm:w-auto">Confirm</AlertDialogAction> </AlertDialogFooter> </AlertDialogContent></AlertDialog>API Reference
Styled Component API
These props are added or materially changed by the installed Astro styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Follow the Primitive and Runtime links for lower-level behavior props.
Alert Dialog Trigger
Inherits button attributes.
Contains the following additional props:
asChild boolean false
- Description
- Merges the component behavior and props into its child element.
- Classification
- Wrapper prop
Alert Dialog Action
Inherits Button props.
Contains the following additional props:
asChild boolean false
- Description
- Merges the component behavior and props into its child element.
- Classification
- Wrapper prop
Alert Dialog Cancel
Inherits Button props.
Contains the following additional props:
asChild boolean false
- Description
- Merges the component behavior and props into its child element.
- Classification
- Wrapper prop
Primitive And Runtime API
Use these references when you need the lower-level behavior APIs behind Alert Dialog.
Primitive API
Runtime API
- Alert Dialog primitive
createAlertDialogfrom@starwind-ui/runtime/alert-dialog
Changelog
v2.0.0
- Rebuilt Alert Dialog on Starwind Runtime for modal state, focus management, and dismissal in confirmation workflows.
- See the Alert Dialog Primitive for the underlying unstyled anatomy and behavior API.