Skip to content
THE COMPONENT LIBRARY
Skip to content

Component reference

Alert

Contextual feedback with a title, supporting text and optional actions.

Preview

Live preview

Changes apply to this preview only.

Loading the interactive example?

Width adapts to the available space

More examples

Different configurations and compositions using the real Pimolu API. Each preview runs independently and follows the site appearance.

Variants

The semantic tone drives the icon, the border and the tinted surface.

Open preview

Anatomy

An optional title, description, body, actions and a dismiss button.

Open preview

Dismissible

The component is controlled: the consumer hides it when onDismiss fires.

Open preview

Usage

Choose a semantic tone and keep the action near the message. onDismiss is controlled: your application must hide the alert when it fires.

Danger defaults to role=alert; other variants default to role=status. Override role only when the announcement behavior suits the situation.

API reference

Generated from the public TypeScript declarations. Native HTML attributes are inherited where the component extends them; this reference includes Pimolu props and selected common native attributes.

PimoluAlertProps

Type source
PimoluAlertProps public API
NameTypeDefaultDescription
variant"neutral" | "success" | "warning" | "danger" | "info" | undefined"info"Semantic tone of the message.
titleReactNode—Short, emphasised summary.
descriptionReactNode—Optional supporting text.
iconReactNode—Decorative leading icon, hidden from assistive technology.
childrenReactNode—Extra content rendered below the description.
actionsReactNode—Action buttons or links rendered at the end of the content.
onDismiss(() => void) | undefined—Shows an accessible close button. The component is controlled: hide it yourself when this callback fires.
dismissLabelstring | undefined"Dismiss alert"Accessible name of the close button.
roleAriaRole | undefined"alert" for danger and "status" for every other variantExplicit landmark role. Defaults to "alert" for danger and "status" for every other variant.
onChangeChangeEventHandler<HTMLDivElement, Element> | undefined—Standard React/HTML attribute.
defaultValuestring | number | readonly string[] | undefined—Standard React/HTML attribute.
classNamestring | undefined—Standard React/HTML attribute.
styleCSSProperties | undefined—Standard React/HTML attribute.
aria-labelstring | undefined—Defines a string value that labels the current element.
onClickMouseEventHandler<HTMLDivElement> | undefined—Standard React/HTML attribute.
variant

"neutral" | "success" | "warning" | "danger" | "info" | undefined

Default: "info"

Semantic tone of the message.

title

ReactNode

No default extracted.

Short, emphasised summary.

description

ReactNode

No default extracted.

Optional supporting text.

icon

ReactNode

No default extracted.

Decorative leading icon, hidden from assistive technology.

children

ReactNode

No default extracted.

Extra content rendered below the description.

actions

ReactNode

No default extracted.

Action buttons or links rendered at the end of the content.

onDismiss

(() => void) | undefined

No default extracted.

Shows an accessible close button. The component is controlled: hide it yourself when this callback fires.

dismissLabel

string | undefined

Default: "Dismiss alert"

Accessible name of the close button.

role

AriaRole | undefined

Default: "alert" for danger and "status" for every other variant

Explicit landmark role. Defaults to "alert" for danger and "status" for every other variant.

onChange

ChangeEventHandler<HTMLDivElement, Element> | undefined

No default extracted.

Standard React/HTML attribute.

defaultValue

string | number | readonly string[] | undefined

No default extracted.

Standard React/HTML attribute.

className

string | undefined

No default extracted.

Standard React/HTML attribute.

style

CSSProperties | undefined

No default extracted.

Standard React/HTML attribute.

aria-label

string | undefined

No default extracted.

Defines a string value that labels the current element.

onClick

MouseEventHandler<HTMLDivElement> | undefined

No default extracted.

Standard React/HTML attribute.

Accessibility

  • Use a clear title and actionable text. Do not rely on the decorative icon for meaning.
  • Avoid filling the initial page with assertive announcements, and give the dismiss button a meaningful label.
Read the accessibility guide →