On this page

Alert

Roles, what Alert gives you and what your team does.

Conformance

Alert meets WCAG 2.2 level AA when used as described on these pages. It follows the Alert pattern of the WAI-ARIA Authoring Practices.

Keyboard

An alert takes no focus. Its action button is in the normal Tab order.

What Alert gives you

  • role="alert" by default, so an alert added to the page is read out at once.
  • Text in color.text on every tint: 12.5:1 or more in light and dark.
  • Role icons at 7.0:1 or more in light and 6.6:1 or more in dark on their tint.

What your team does

  • Pass role="status" (or role="note") for a banner that is on the page when it loads, so it is not read out over everything else.
  • Add the alert to the page when the event happens; don’t show and hide one that was always there.
  • Say the status in words in the title. The colour and icon are extra cues.
  • Don’t move focus to an alert. If people must act on it now, use an alert dialog.
  • Give the action button a label that makes sense on its own.

WCAG criteria

Criterion Level How
1.3.1 Info and Relationships A Title and description are text in reading order
1.4.1 Use of Color A Status said in words and with an icon, not by colour alone
1.4.3 Contrast (Minimum) AA 12.5:1 or more
4.1.3 Status Messages AA role="alert" or role="status"