structyl

Alert Dialog API

View component

The full prop reference for the Alert Dialog component. A modal dialog that interrupts the user and expects a response.

Import

tsx
import { AlertDialog } from '@structyl/styled';

Props

Root

Root provider component for AlertDialog; controls open state and focus management. Always forces modal=true.

PropTypeDefault
open#boolean

Controlled open state of the dialog

defaultOpen#boolean

Initial open state when uncontrolled

false
onOpenChange#(open: boolean) => void

Callback fired when open state changes

children#React.ReactNode

Dialog subcomponents

Trigger

Button that opens the dialog. Accepts all standard button HTML attributes.

PropTypeDefault
asChild#boolean

Render as child element, passing props to first child

className#string

CSS class name

onClick#(event: React.MouseEvent<HTMLButtonElement>) => void

Click event handler (composed with open toggle)

Portal

Portal container that renders dialog content at document root (or custom container)

PropTypeDefault
children#React.ReactNode

Portal children (typically Overlay, Content)

container#Element | DocumentFragment | null

DOM node to render portal into; defaults to body

forceMount#boolean

Force mounting of portal content even when dialog is closed

Overlay

Semi-transparent backdrop behind the dialog. Styled wrapper around dialog overlay.

PropTypeDefault
asChild#boolean

Render as child element, passing props to first child

className#string

CSS class name; defaults include fixed inset-0 z-50 bg-overlay/60 and animations

forceMount#boolean

Force mounting even when dialog is closed

style#React.CSSProperties

Inline styles

Content

Main dialog content container with role='alertdialog'. Automatically prevents outside interaction and auto-focuses cancel button.

PropTypeDefault
asChild#boolean

Render as child element, passing props to first child

className#string

CSS class name; defaults include fixed positioning, max-w-lg, rounded-2xl, and animations

forceMount#boolean

Force mounting even when dialog is closed

onEscapeKeyDown#(event: KeyboardEvent) => void

Callback when Escape key pressed inside dialog

onOpenAutoFocus#(event: Event) => void

Callback before focus moves to content on open; can preventDefault to skip default focus behavior

onCloseAutoFocus#(event: Event) => void

Callback before focus returns on close

style#React.CSSProperties

Inline styles

Header

Convenience wrapper container for Title and Description; uses flexbox column with gap and text alignment.

PropTypeDefault
className#string

CSS class name; defaults to flex flex-col gap-2 text-center sm:text-left

children#React.ReactNode

Header content

style#React.CSSProperties

Inline styles

Title

Dialog title heading (h2). Styled with text-lg font-semibold.

PropTypeDefault
asChild#boolean

Render as child element, passing props to first child

className#string

CSS class name; defaults to text-lg font-semibold

children#React.ReactNode

Title text

style#React.CSSProperties

Inline styles

Description

Dialog description paragraph (p). Styled with text-sm text-muted-foreground.

PropTypeDefault
asChild#boolean

Render as child element, passing props to first child

className#string

CSS class name; defaults to text-sm text-muted-foreground

children#React.ReactNode

Description text

style#React.CSSProperties

Inline styles

Action

Primary action button (typically confirm/destructive). Styled with default button variants.

PropTypeDefault
asChild#boolean

Render as child element, passing props to first child

className#string

CSS class name; defaults to buttonVariants() styles

onClick#(event: React.MouseEvent<HTMLButtonElement>) => void

Click event handler (composed with dialog close)

children#React.ReactNode

Button text

type#'button' | 'submit' | 'reset'

Button type

'button'
disabled#boolean

Disable the button

style#React.CSSProperties

Inline styles

Cancel

Cancel button (typically secondary). Styled with outline variant and auto-focused on dialog open.

PropTypeDefault
asChild#boolean

Render as child element, passing props to first child

className#string

CSS class name; defaults to buttonVariants({ variant: 'outline' }) plus mt-2 sm:mt-0

onClick#(event: React.MouseEvent<HTMLButtonElement>) => void

Click event handler (composed with dialog close)

children#React.ReactNode

Button text

type#'button' | 'submit' | 'reset'

Button type

'button'
disabled#boolean

Disable the button

ref#React.Ref<HTMLButtonElement>

Forwarded ref; automatically connected to cancel focus management

style#React.CSSProperties

Inline styles

Source code

If you didn't find what you need here, read the component implementation .

structyl — Accessible React Component Library