Alert Dialog
A dialog that requires user response to proceed.
API reference
Import the component and assemble its parts:
import { AlertDialog } from '@base-ui-components/react/alert-dialog';
<AlertDialog.Root>
<AlertDialog.Trigger />
<AlertDialog.Portal>
<AlertDialog.Backdrop />
<AlertDialog.Popup>
<AlertDialog.Title />
<AlertDialog.Description />
<AlertDialog.Close />
</AlertDialog.Popup>
</AlertDialog.Portal>
</AlertDialog.Root>
Root
Groups all parts of the alert dialog. Doesn’t render its own HTML element.
Prop | Type | Default | |
---|---|---|---|
defaultOpen |
|
| |
open |
|
| |
onOpenChange |
|
|
Trigger
A button that opens the alert dialog.
Renders a <button>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-popup-open | Present when the corresponding dialog is open. |
Portal
A portal element that moves the popup to a different part of the DOM.
By default, the portal element is appended to <body>
.
Prop | Type | Default | |
---|---|---|---|
container |
|
| |
keepMounted |
|
|
Backdrop
An overlay displayed beneath the popup.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
keepMounted |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-open | Present when the dialog is open. | |
data-closed | Present when the dialog is closed. | |
data-starting-style | Present when the dialog is animating in. | |
data-ending-style | Present when the dialog is animating out. |
Popup
A container for the alert dialog contents.
Renders a <div>
element.
Prop | Type | Default | |
---|---|---|---|
initialFocus |
|
| |
finalFocus |
|
| |
className |
|
| |
keepMounted |
|
| |
render |
|
|
Attribute | Description | |
---|---|---|
data-open | Present when the dialog is open. | |
data-closed | Present when the dialog is closed. | |
data-has-nested-dialogs | Present when the dialog has other open dialogs nested within it. | |
data-nested | Present when the dialog is nested within another dialog. | |
data-starting-style | Present when the dialog is animating in. | |
data-ending-style | Present when the dialog is animating out. |
Title
A heading that labels the dialog.
Renders an <h2>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|
Description
A paragraph with additional information about the alert dialog.
Renders a <p>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|
Close
A button that closes the alert dialog.
Renders a <button>
element.
Prop | Type | Default | |
---|---|---|---|
className |
|
| |
render |
|
|