Skip to content

Alert

An in-page status message with a type icon, optional actions and close button.

Some logs in this time range may have been archived.
Archived logs are kept for 30 days and can be exported.
hero.tsx

Usage guidelines

  • Use Alert for a status that stays relevant while the user works on the surrounding content, such as an archived range, a conflicting edit or a form rejection that belongs to no field. Feedback on an action that is over once it is seen is a Toast, and a decision the user must answer before continuing is an AlertDialog.
  • type sets the icon, the halo and the default role. An error alert uses role="alert" and interrupts assistive technology; the other types use role="status" and wait for a pause.
  • Pass role when the default does not fit. An error that is already present when the page loads, rather than the result of something the user did, takes a non-live role such as note so it does not interrupt.
  • The icon comes from type and cannot be replaced. A banner that needs a product or business icon is not an Alert.
  • Every alert has an AlertTitle. A one-sentence message uses the title alone; add AlertDescription for detail and AlertActions for buttons below the text, using small Buttons.
  • AlertClose is a stateless button with a required aria-label. The caller owns whether the alert is visible, whether the dismissal persists and where focus goes, because the focused close button leaves the page with the alert.

Anatomy

tsx
tsx

Alert renders the icon and halo for its type and lays out the content beside it. AlertClose sits at the inline end and the content reserves space for it.

Examples

Types

info, success, warning and error set the icon, the halo and the default role. These alerts are present when the page loads, so the error alert passes role="note".

Changes to this connection apply to every app that uses it.
The connection is ready.
This connection was updated by someone else.
The last sync of this connection failed.
types.tsx

Actions

AlertActions places buttons below the title and description.

Knowledge base index is out of date.
Three documents changed since the last sync. Re-index to include the latest edits in retrieval.
actions.tsx

Dismissible

AlertClose only reports the click. The caller removes the alert, moves focus to the button that replaces it and decides when the alert comes back.

This sample app has limited trial messages. Create your own copy to keep using it.
dismissible.tsx

API reference

Alert

An in-page status message with a semantic icon and background halo. Renders a <div> element.

Sets role="alert" when type="error" and role="status" otherwise; pass role explicitly when an error is already present on load.

Props
PropTypeDefaultDetails
type required'error' | 'info' | 'success' | 'warning'No default
Data attributes
AttributeDescription
data-type

Values: 'info' | 'success' | 'warning' | 'error'

The alert type, which sets the icon, the halo and the default role.

AlertActions

Accepts the props of the element it renders.

AlertClose

A stateless close button for dismissing an alert; callers own visibility state. Renders a <button> element.

Base UI Button docs

Props
PropTypeDefaultDetails
aria-label requiredstringNo default
Base UI Button docs
Data attributes
AttributeDescription
data-disabled

Present when the button is disabled.

AlertDescription

AlertTitle