Installation
Usage
Props
AlertDialog
| Prop | Type | Default | Description |
|---|---|---|---|
heading | string | - | Required. Header text for the Alert Dialog. |
isOpen | boolean | - | Required. Determines whether the Alert Dialog is open. |
onConfirm | () => void | - | Required. Function to run when the confirm button is clicked. |
onConfirmLabel | string | - | Required. Label for the confirm button. |
onDismiss | () => void | - | Required. Function to run when the dismiss button is clicked or dialog is closed. |
onDismissLabel | string | - | Required. Label for the dismiss button. |
children | React.ReactNode | - | Required. The message body content. |
destructive | boolean | false | Display a destructive Alert Dialog with warning styling. |
isConfirmDisabled | boolean | false | Disable the confirm button. |
element | string | "ALERT_DIALOG" | Overrides the default element name for custom styling with the Customization Provider. |
Examples
Default Alert Dialog
Destructive Alert Dialog
Disabled Confirm Button
Accessibility
- AlertDialog uses
role="alertdialog"for screen readers - Both
aria-labelledbyandaria-describedbyare automatically set - Focus is trapped within the dialog when open
- Pressing Escape triggers the
onDismisscallback - Clicking outside the dialog triggers the
onDismisscallback - The dialog is announced to screen readers when it opens
When to Use
Use Alert Dialog when:
- You need to interrupt the user’s workflow for critical information
- You need confirmation before performing a destructive action
- The user must acknowledge important information before continuing
- You need a simple yes/no or confirm/cancel response
Use Modal instead when:
- You need a more complex form or multi-step workflow
- The content is not urgent or critical
- You need custom header content or multiple sections
- The dialog doesn’t require an immediate binary decision