Alerts

An alert gives users important information about their current task, without them having to leave the screen.

Wrap any text and an optional dismiss button in .alert for basic alert messages.


Anatomy

  1. Container
  2. Icon
  3. Body content
  4. Close (optional)
Alert anatomy diagram

Types of alert

Options

You have four types to choose from: success, info, warning and error. Pick the one that best fits the message you're trying to convey.

Please keep in mind that the icons for these message types can't be changed.

To apply a type to your alert message simply add one of the following classes: .alert-success, .alert-info, .alert-warning or .alert-danger.

Success .alert-success

Info .alert-info

Warning .alert-warning

Danger .alert-danger

Title

A bolded title is optional. Use a title to quickly summarise the purpose of the notice. Keep titles short, no more than 60 characters, and avoid repeating the body text.

Alert with title

We include the ability to add a link within an alert message because an alert by itself is often just the start of a conversation. The link transforms the alert from a passive notification into an actionable next step.

Alert with link


Dismiss

Alert notices can include a dismiss button that removes the notice from the page layout. This is helpful for general or supplemental information. The user needs to actively close the alert.

Build on any alert by adding an optional .alert-dismissible and close button.

Close icon

The decision to hide the close icon should be deliberate and reserved only for alerts that represent a mandatory acknowledgement or a system-controlled status change. If the user can ignore the message, they must be given the option to dismiss it.

Max/min width

Having a defined max and min width for an alert is crucial for readability and visual consistency.

A minimum width ensures the alert's content isn't cramped and remains easy to read, whilst a maximum width prevents text lines from becoming too long, which can strain the user's eyes and make the message harder to scan.

Alerts have a minimum width of 300px and a maximum width of 800px.

Max width max-width: 800px

Min width min-width: 300px

Usage

Placing alerts in the top middle of the screen is a best practice in a design system for visibility and user focus. This position is a prime location that ensures the message is seen without being overly intrusive.


Accessibility

Keyboard interaction

All interactive elements within an alert should be reachable via TAB and SHIFT+TAB keys.

Always use role="alert" on alert containers to announce the alert to screen readers. Close buttons must include aria-label="Close" for screen reader users.

Add tabindex="0" to make alerts focusable via keyboard. A focus outline is displayed when the alert receives focus.

Focusable alert tabindex="0"


Best practices

One alert at a time

Show only one alert at a time. Once a user dismisses or addresses it, replace it with the next most important notice.

Avoid stacking alerts — they can quickly become overwhelming.


Sizing

Small alert

Fancy small alerts? Add .alert-sm for the small version.

Success .alert-success.alert-sm

Info .alert-info.alert-sm

Warning .alert-warning.alert-sm

Danger .alert-danger.alert-sm

Medium icons

For a medium icon size add .alert-icon-md to the alert main wrapper.

Success .alert-success.alert-icon-md

Info .alert-info.alert-icon-md

Warning .alert-warning.alert-icon-md

Danger .alert-danger.alert-icon-md

Large icons

For a large icon size add .alert-icon-lg to the alert main wrapper.

Success .alert-success.alert-icon-lg

Info .alert-info.alert-icon-lg

Warning .alert-warning.alert-icon-lg

Danger .alert-danger.alert-icon-lg