GitHub

Alert Dialog

Modal dialog for important confirmations requiring user action

Basic Usage

Loading...

Installation

pnpm add @corew500/ui

Usage

import { AlertDialog } from "@corew500/ui/alert-dialog"

<AlertDialog>Content</AlertDialog>

CMS Integration

CMSPayload CMS Integration
This component supports CMS-driven content via @corew500/cms-payload.
Loading...

API Reference

Props

PropTypeDefaultDescription
onOpenChange(open: boolean, eventDetails: AlertDialogRootChangeEventDetails) => voidEvent handler called when the dialog is opened or closed.
actionsRefRefObject<DialogRootActions>A ref to imperative actions. - `unmount`: When specified, the dialog will not be unmounted when closed. Instead, the `unmount` function must be called to unmount the dialog manually. Useful when the dialog's animation is controlled by an external library. - `close`: Closes the dialog imperatively when called.
handleDialogHandle<unknown>A handle to associate the alert dialog with a trigger. If specified, allows external triggers to control the alert dialog's open state. Can be created with the AlertDialog.createHandle() method.
openenumWhether the dialog is currently open.
defaultOpenenumfalseWhether the dialog is initially open. To render a controlled dialog, use the `open` prop instead.
onOpenChangeComplete(open: boolean) => voidEvent handler called after any animations complete when the dialog is opened or closed.
triggerIdstringID of the trigger that the dialog is associated with. This is useful in conjunction with the `open` prop to create a controlled dialog. There's no need to specify this prop when the popover is uncontrolled (i.e. when the `open` prop is not set).
defaultTriggerIdstringID of the trigger that the dialog is associated with. This is useful in conjunction with the `defaultOpen` prop to create an initially open dialog.

Accessibility

Keyboard Navigation

  • Escape key closes dialog (if enabled)
  • Tab/Shift+Tab cycles through focusable elements

Focus Management

  • Focus is trapped within the dialog when open
  • Focus returns to trigger when closed

Screen Readers

  • - Uses `role="alertdialog"` for proper screen reader announcement
  • Title associated via `aria-labelledby`
  • Description associated via `aria-describedby`

Localization

Translatable Content

  • - Component accepts pre-resolved strings for all text content
  • `AlertDialogTitle` children should be translated
  • `AlertDialogDescription` children should be translated
  • Button labels in `AlertDialogAction` and `AlertDialogCancel` should be translated