Skip to main content

Starwind UI v3.0 is now available! Migration guide

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

---
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>

Composition

Use this structure for an alert dialog:

AlertDialog
โ”œโ”€โ”€ AlertDialogTrigger
โ””โ”€โ”€ AlertDialogContent
โ”œโ”€โ”€ AlertDialogHeader
โ”‚ โ”œโ”€โ”€ AlertDialogTitle
โ”‚ โ””โ”€โ”€ AlertDialogDescription
โ””โ”€โ”€ AlertDialogFooter
โ”œโ”€โ”€ AlertDialogCancel
โ””โ”€โ”€ AlertDialogAction

When to Use

Use an alert dialog when the user must confirm a critical action or acknowledge important information before continuing.

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

Styled Component API

These props are added or materially changed by the installed styled component. Standard HTML attributes remain available through the inherited interfaces noted below. Expand a prop to see named type definitions and framework-specific imports. Follow the Primitive and Runtime links for lower-level behavior props.

Alert Dialog Trigger

Inherits button attributes.

Contains the following additional props:

Prop Type Default Toggle details
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:

Prop Type Default Toggle details
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:

Prop Type Default Toggle details
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.

Runtime API

Alert Dialog primitive
createAlertDialog from @starwind-ui/runtime/alert-dialog

Changelog

View version history v2.0.2 2 releases

v2.0.2

  • Named the generated aggregate default export so React and Astro tooling can identify the installed component cleanly.

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.