Skip to main content
Kaleidoscope

Alert

Alerts are used for in-context hints, either to help guide them to an action, or in response to a given action.

Best practices

  • The Alert component should be used contextually near a set of related controls (for example, within a form); a Notification is better suited for broadcast messages

Types

There are two alert types currently.

AlertType.Info should be used for guidance to help a user perform an action.

AlertType.Error should be used to inform a user in response to an action that was not completed successfully.

Editable example

Alignment

By default, the heading and body are left-aligned.

Use AlignmentType.Center within alerts with narrow widths, or with alerts that sit in context of other center aligned elements

Editable example

Theming

The Alert component supports theming via the theme prop. By default it will use AlertTheme.Light, but you can also provide AlertTheme.Dark for a darker theme.

Editable example

Note that the dark theme doesn't work with AlertType.Error right now.

Dismissable alert

If you want a dismissable alert, you can pass a function as the onDismiss prop. This will add a dismiss button to the top right hand corner of the component.

Editable example

Accessibility

AlertType.Error applies the ARIA 'alert' role, so be considerate to only use when immediate attention is required.