Alert

Figma logo The guideline content on this page is synced with Figma and can be used as a source of truth. Open in Figma

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


Anatomy

  1. Container
  2. Icon
  3. Body content
  4. Close (optional)
Alert anatomy diagram showing the container, icon, body content and optional close button

Types of alert

You have four types to choose from: success, information, 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.

  1. Success
  2. Info
  3. Warning
  4. Error

Success .alert-success

Info .alert-info

Warning .alert-warning

Error .alert-danger


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


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 a bold title above the body text

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.

Alert with a dismiss button in the top-right corner

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.

Alert minimum width of 300px and maximum width of 800px

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.

Alert placed in the top middle of the screen, above the page content

Accessibility

Keyboard interaction

All components should be reachable via TAB and SHIFT+TAB keys.

The alert itself has no focus state and is not focusable, but any actions inside it are focusable and have their own focus state.


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.

Do

Show a single alert so the message stays clear and easy to act on.

Don't

Avoid stacking multiple alerts — they compete for attention and quickly become overwhelming.


Specs

Alert specs: 4px corner radius, 16px padding, 16px gap between the icon and content, 8px gap between the body and link

Developer reference

The following sections describe supported functionality that is not part of the Figma design specification.


Options

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

To apply a type, add one of the following classes: .alert-success, .alert-info, .alert-warning or .alert-danger. .alert-error is kept as a legacy alias of .alert-danger — both produce identical output.

When no type class is applied, the alert uses the .alert-info appearance by default.

Success .alert-success


Dismiss button

Add .alert-dismissible to the alert and include a dismiss button. The dismiss button is the small Icon Button (.btn.btn-icon.btn-sm) with a spirisicon-close glyph and an aria-label="Close". This Icon Button replaces the .close helper class: .alert positions and spaces its dismiss control from .btn-icon, so a bare .close there is never positioned at all.

The Spiris package ships CSS only, so removing the alert from the page is the consumer's responsibility (see the example markup's data-dismiss="alert" hook).


Accessibility

Always use role="alert" on the alert container so the message is announced to screen readers.

The dismiss button must include aria-label="Close" for screen reader users.

The alert container is not focusable — only the interactive elements inside it (the dismiss button and any links) are keyboard-focusable, each with its own focus state.


Small alert

Add .alert-sm for a smaller, more compact alert.

Success .alert-success.alert-sm

Info .alert-info.alert-sm

Warning .alert-warning.alert-sm

Error .alert-danger.alert-sm