Axon 911 Frontend DocsAxon 911 Frontend Docs
Axon 911 Frontend Docs
    Loading navigation…
U
User
Switch to light mode
  1. Components
  2. Alert Dialog
  3. API and Development

Alert Dialog

API and Development

View SourceOpens in a new tabSubmit IssueOpens in a new tab
Import AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogFooter, AlertDialogTrigger, AlertDialogSize from @prepared911/ui/alert-dialog.
AlertDialog
PropTypeNotes
openbooleanControlled open state.
defaultOpenbooleanInitial state when uncontrolled. Defaults to false.
onOpenChange(open: boolean, details: AlertDialogOpenChangeDetails) => voidOne call per request. details.reason is a PopupOpenChangeReason; details.cancel() vetoes a cancelable request. A press on the cancel or the action reports close-press with details.source set to the Button.
initialFocusAlertDialogFocusTargetRef or function; focused right after the dialog opens. Defaults to the AlertDialogCancel Button.
finalFocusAlertDialogFocusTargetRef or function; focused after every close.
childrenReactNodeAlertDialogTrigger and AlertDialogContent.
AlertDialogTrigger
PropTypeNotes
childrenAlertDialogControlElementOne Button or Link. Receives onClick, ref, aria-haspopup="dialog", and aria-expanded.
AlertDialogContent
PropTypeNotes
titleLocalizedMessageRequired. Heading (h2) that names the dialog through aria-labelledby.
descriptionLocalizedMessageRequired. Referenced by aria-describedby.
sizeAlertDialogSizeMedium (default, --dialog-width-md, 512px) or Small (--dialog-width-sm, 384px).
refRef<HTMLDialogElement>The dialog element.
classNamestringAppended after the generated classes.
childrenReactNodeUsually one AlertDialogFooter.
The surface has role="alertdialog" and aria-modal="true". It carries data-open while open and data-ending-style during the exit transition. There is no hideTitle, aria-label, or role prop.
AlertDialogFooter
PropTypeNotes
childrenReactNodeAlertDialogCancel then AlertDialogAction. They wrap on narrow dialogs.
AlertDialogCancel
PropTypeNotes
childrenAlertDialogControlElementOne Button. Receives onClick, which reports a cancelable close-press, and a ref that marks it as the default initial focus. Its own onClick runs first and its own ref still attaches.
AlertDialogAction
PropTypeNotes
childrenAlertDialogControlElementOne Button. Its own onClick runs first and performs the action; the dialog then reports a cancelable close-press.
Props
NameTypeDefaultDescription
childrenReactNode—{@link AlertDialogTrigger } and {@link AlertDialogContent }, in any order.
defaultOpenbooleanfalseInitial open state when uncontrolled.
finalFocusPopupFocusTarget—Focused after every close. Omit to return focus to the element that was focused before the dialog opened.
initialFocusPopupFocusTarget—Focused right after the dialog opens. Omit to focus {@link AlertDialogCancel }, the least destructive action. Pass a target, such as the action, for a confirmation that is not destructive.
onOpenChange((open: boolean, details: DialogOpenChangeDetails) => void)—Called once per open or close request: trigger press, cancel or action press (close-press), and Escape (close-request). A backdrop press never closes an alert dialog. A cancelable request is vetoed with details.cancel(); details.source is the pressed Button for a close-press.
openboolean—Controlled open state. Pair with {@link AlertDialogProps.onOpenChange}.
Storybook
Interactive examples and edge cases for this component are in Storybook.
DefaultOpens in a new tab
Previous
Alert Dialog / Usage
Next
Alert Dialog / Accessibility
On this page
AlertDialog
AlertDialogTrigger
AlertDialogContent
AlertDialogFooter
AlertDialogCancel
AlertDialogAction
Props
Storybook