Skip to content

Dialog

A wrapper around React Aria’s DialogTrigger, Modal, and Dialog components. Focus is trapped inside the dialog while it is open and returns to the trigger on close.

Terminal window
npx @a2ra/cli add dialog
{
"type": "Dialog",
"props": {
"triggerLabel": "Delete account",
"title": "Delete account",
"description": "This will permanently delete your account and all data.",
"role": "alertdialog",
"isDismissable": false
},
"children": [
{
"type": "Flex",
"props": { "gap": "sm", "justify": "end" },
"children": [
{ "type": "Button", "props": { "variant": "secondary" }, "children": "Cancel" },
{ "type": "Button", "props": { "variant": "danger" }, "children": "Delete" }
]
}
]
}
PropTypeDescription
triggerLabelstringLabel for the button that opens the dialog
titlestringDialog heading
descriptionstringSupporting text shown below the title
roledialog default
alertdialog
ARIA role (alertdialog prevents dismissal by clicking outside)
isDismissabletrue default
false
Allow closing by clicking the backdrop
isKeyboardDismissDisabledtrue
false default
Prevent Escape from closing
isOpenbooleanControlled open state
defaultOpentrue
false default
Open on mount
childrennode[]Content rendered inside the dialog body
  • role: "alertdialog" tells screen readers this is a message requiring attention; it also disables backdrop-click dismissal regardless of isDismissable.
  • Focus is trapped inside the dialog and returns to the trigger on close.
  • Escape closes the dialog by default unless isKeyboardDismissDisabled is true.