Alerts

An alert is an element that displays a brief, important message in a way that attracts the user's attention without interrupting the user's task.

Variations

Simple alerts

copydone
copydone
copydone
copydone
copydone

Alerts with title and supportive text

copydone
copydone
copydone
copydone
copydone

Alerts with icons

copydone
copydone
copydone
copydone
copydone

Alerts with icons, title and supportive text

copydone
copydone
copydone
copydone
copydone

Dismissible alerts Requires JS

copydone
copydone
copydone
copydone
copydone

Dismissible alerts with action button Requires JS

copydone
copydone
copydone
copydone
copydone

Dismissible alerts with title, icon, text and actions Requires JS

copydone
copydone
copydone
copydone
copydone

Usage

Use an alert component to display a brief, important message in a way that will attract the user's attention without interrupting the user's task. Alerts can use colors to indicate the message's importance (info, warning, danger etc).

Specs

Alerts have an internal padding of 1rem (16px) horizontally and 0.75rem (12px) vertically. They can include the following elements:

  • Title: 0.875rem (14px) font size and semibold weight.
  • Supportive text: 0.875rem (14px) font size.
  • Icon: 1.25rem (20px) width and height.
  • Dismissible button: an icon-only button, small size (see buttons ).
  • Action buttons: a text-only button, small size (see buttons ).

Accessibility notes

To make the alerts accessible a role="alert" role is required to communicate the importance of the message to the user. When this role is added to the alert element, the browser will send out an accessible alert event to assistive technology products which can then notify the user.