structyl

Alert Dialog

stable

A modal dialog that interrupts the user and expects a response.

Basic usage

Examples

With async action

Disable the action button while async work is in progress.

Destructive confirmation

AlertDialog blocks outside interaction and starts focus on the safest action.

Features

  • Focus starts on Cancel.
  • Outside interaction is blocked.

Installation

bash
pnpm dlx structyl add alert-dialog

API Reference

AlertDialog.Root

A confirmation dialog requiring an explicit choice.

PropTypeDefault
openboolean

Controlled open state.

defaultOpenboolean

Initial open state.

onOpenChange(open: boolean) => void

Called when open state changes.

AlertDialog.Trigger

Opens the alert dialog.

PropTypeDefault
asChildboolean

Merge props onto the immediate child instead of rendering a default element.

false

AlertDialog.Content

The dialog body. Outside interaction is blocked.

PropTypeDefault
onOpenAutoFocus(event) => void

Customize initial focus.

AlertDialog.Cancel

The cancelling action. Receives initial focus.

PropTypeDefault
asChildboolean

Merge props onto the immediate child instead of rendering a default element.

false

AlertDialog.Action

The confirming action.

PropTypeDefault
asChildboolean

Merge props onto the immediate child instead of rendering a default element.

false

AlertDialog.Title

Accessible dialog title.

PropTypeDefault

AlertDialog.Description

Accessible dialog description.

PropTypeDefault
Alert Dialog | structyl