Alert

The Alert component is used to display important messages to the user with support for different variants and actions.

Usage & Examples

Default

Notification saved
This alert can be dismissed.
default.tsx
<Alert title="Notification saved" state="info" dismissLabel="Close notification" icon={<FaInfoCircle />} dismissible>
    This alert can be dismissed.
  </Alert>

Theme Mappings

Primary theme
Use themes for brand-colored, non-semantic messages.
Secondary theme
Secondary styling can support related product messaging.
Tertiary theme
Tertiary styling provides another visual emphasis level.
Quaternary theme
Quaternary styling rounds out the configured theme palette.
theme-mappings.tsx
<Alert title="Primary theme" theme="primary">Primary message</Alert>
  <Alert title="Secondary theme" theme="secondary">Secondary message</Alert>
  <Alert title="Tertiary theme" theme="tertiary">Tertiary message</Alert>
  <Alert title="Quaternary theme" theme="quaternary">Quaternary message</Alert>

Semantic States

Changes saved
Your profile is up to date.
Review recommended
Two settings still use their default values.
Update available
A newer version is ready to install.
semantic-states.tsx
<Alert title="Changes saved" state="success" icon={<FaCheckCircle />}>
    Your profile is up to date.
  </Alert>
  <Alert title="Review recommended" state="warning" icon={<FaExclamationTriangle />}>
    Two settings still use their default values.
  </Alert>
  <Alert title="Unable to save" state="error" icon={<FaExclamation />}>
    Check the highlighted fields and try again.
  </Alert>
  <Alert title="Update available" state="info" icon={<FaInfoCircle />}>
    A newer version is ready to install.
  </Alert>

Surface Variants

Solid
Strong emphasis for important feedback.
Soft
Lower emphasis while preserving the semantic mapping.
Outline
A lightweight treatment for supporting information.
Glass
A translucent treatment for layered interfaces.
Glass outline
A transparent surface with a defined semantic border.
surface-variants.tsx
<Alert title="Solid" state="info" variant="solid">Strong emphasis</Alert>
  <Alert title="Soft" state="info" variant="soft">Lower emphasis</Alert>
  <Alert title="Outline" state="info" variant="outline">Lightweight treatment</Alert>
  <Alert title="Glass" state="info" variant="glass">Translucent treatment</Alert>
  <Alert title="Glass outline" state="info" variant="glassOutline">Transparent surface</Alert>

Props API

22 props
Columns
Alert props API
Default
Description
actionsReactNodeNoprops—Action content rendered by the component.
actionsClassNamestringNoprops—Additional CSS class names for the actions section.
childrenReactNodeNoprops—Content rendered inside the component.
classNamestringNostyling—Additional CSS class names for the component root.
contentClassNamestringNoprops—Additional CSS class names for the content section.
data-testidstringNotesting—Test id used to identify the component in tests.
dismissButtonClassNamestringNoprops—Additional CSS class names for the dismiss button section.
dismissiblebooleanNopropsfalseDismissible.
dismissLabelstringNoprops"Dismiss alert"Dismiss Label.
iconReactNodeNoprops—Icon rendered by the component.
iconClassNamestringNoprops—Additional CSS class names for the icon section.
messageClassNamestringNoprops—Additional CSS class names for the message section.