Alert Dialog

A dialog that requires user response to proceed.

API reference

Import the component and place its parts the following way:

Anatomy
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.

PropTypeDefault
defaultOpenbooleanfalse
onOpenChange(open, event) => voidundefined
openbooleanundefined

Trigger

A button that opens the alert dialog. Renders a <button> element.

PropTypeDefault
classNamestring | (state) => stringundefined
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
Attribute
Description
data-popup-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>.

PropTypeDefault
containerReact.Ref | HTMLElement | nullundefined
keepMountedbooleanfalse

Backdrop

An overlay displayed beneath the popup. Renders a <div> element.

PropTypeDefault
classNamestring | (state) => stringundefined
keepMountedbooleanfalse
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
Attribute
Description
data-closed
data-ending-style
data-open
data-starting-style

A container for the alert dialog contents. Renders a <div> element.

PropTypeDefault
classNamestring | (state) => stringundefined
finalFocusReact.Refundefined
initialFocus| React.Ref
| (interactionType => HTMLElement | null)
undefined
keepMountedbooleanfalse
render| React.ReactElement
| (props, state) => React.ReactElement
undefined
Attribute
Description
data-closed
data-ending-style
data-nested-dialogs
data-open
data-starting-style

Title

A heading that labels the dialog. Renders an <h2> element.

PropTypeDefault
classNamestring | (state) => stringundefined
render| React.ReactElement
| (props, state) => React.ReactElement
undefined

Description

A paragraph with additional information about the alert dialog. Renders a <p> element.

PropTypeDefault
classNamestring | (state) => stringundefined
render| React.ReactElement
| (props, state) => React.ReactElement
undefined

Close

A button that closes the alert dialog. Renders a <button> element.

PropTypeDefault
classNamestring | (state) => stringundefined
render| React.ReactElement
| (props, state) => React.ReactElement
undefined