Skip to main content

Starwind UI v1.12 is now available!

Alert Dialog

Are you absolutely sure?

This action cannot be undone. This will permanently delete your account and remove your data from our servers.

Installation

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.

Delete Account

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.

Custom Styling

You can customize the appearance of alert dialog components using the class prop.

Custom Alert Dialog

This alert dialog has custom styling applied to make it more compact and centered.

API Reference

AlertDialog

The root component that manages the alert dialog state.

PropTypeDefault
classstring-
<AlertDialog>
<!-- Contains all alert dialog components -->
</AlertDialog>

AlertDialogTrigger

A button that opens the alert dialog when clicked.

PropTypeDefault
asChildbooleanfalse
forstring-
classstring-
<AlertDialogTrigger asChild>
<Button>Open Alert</Button>
</AlertDialogTrigger>

Additional Notes:

  • asChild: When enabled, renders the child element instead of a button
  • for: Optional ID of the dialog to trigger

AlertDialogContent

The modal content container that appears when the alert dialog is opened.

PropTypeDefault
animationDurationnumber200
classstring-
<AlertDialogContent animationDuration={300}>
<!-- Alert dialog content goes here -->
</AlertDialogContent>

Additional Notes:

  • animationDuration: Open and close animation duration in milliseconds

AlertDialogHeader

A container for the alert dialog title and description.

PropTypeDefault
classstring-
<AlertDialogHeader>
<AlertDialogTitle>Confirm Action</AlertDialogTitle>
<AlertDialogDescription>Are you sure?</AlertDialogDescription>
</AlertDialogHeader>

AlertDialogTitle

The title of the alert dialog. Automatically receives proper heading semantics.

PropTypeDefault
classstring-
<AlertDialogTitle>
Delete Account
</AlertDialogTitle>

AlertDialogDescription

A description that provides additional context about the alert.

PropTypeDefault
classstring-
<AlertDialogDescription>
This action cannot be undone. Your data will be permanently deleted.
</AlertDialogDescription>

AlertDialogFooter

A container for action buttons, typically containing cancel and confirm buttons.

PropTypeDefault
classstring-
<AlertDialogFooter>
<AlertDialogCancel>Cancel</AlertDialogCancel>
<AlertDialogAction>Confirm</AlertDialogAction>
</AlertDialogFooter>

AlertDialogAction

A button that performs the primary action and closes the alert dialog.

PropTypeDefault
asChildbooleanfalse
classstring-
<AlertDialogAction asChild>
<Button variant="error">Delete</Button>
</AlertDialogAction>

Additional Notes:

  • asChild: When enabled, renders the child element instead of a button

AlertDialogCancel

A button that cancels the action and closes the alert dialog.

PropTypeDefault
asChildbooleanfalse
classstring-
<AlertDialogCancel>Cancel</AlertDialogCancel>

Additional Notes:

  • asChild: When enabled, renders the child element instead of a button

Changelog

v1.0.2

  • use class:list to remove potential “undefined” on AlertDialogAction and AlertDialogCancel

v1.0.1

  • Add named slot “backdrop” to AlertDialogContent to enable backdrop replacement

v1.0.0

  • Initial release with starwind v1.9.0