Skip to content

role alert

Alert draft v0.1.0

A brief, important message that draws attention without interrupting the task.

An alert tells people something important about the page or what they just did: a saved change, a failed payment, a maintenance window, a quota about to run out. It sits in the content, tinted by its intent with an icon and a title, and is announced by assistive technology when it appears. It never moves focus and never blocks the page: a message that needs a decision is a dialog, a short transient confirmation is a toast.

Guidelines

From apps/docs/content/components/alert.md

Overview

An alert tells people something important about the page or about what they just did: a change was saved, a payment failed, maintenance is coming, a quota is almost reached. It sits in the content, tinted by its intent, with an icon and a title, and assistive technology announces it when it appears. It never moves focus and never blocks the page.

This page applies to every platform. Where a platform differs, the difference sits under a sub-heading named after it (Web, iOS, Android, Desktop); everything else holds everywhere.

When to use

  • Feedback after an action, shown in the page (Changes saved, Payment failed).
  • Information about the page or the account that people should notice (a maintenance window, a quota).
  • A summary of the errors of a form, above the form, with the fields named.

When not to use

  • A decision is needed before continuing. Use a dialog: an alert never blocks.
  • A short confirmation that can disappear by itself. Use a toast.
  • A status of one item. Use a Badge.
  • An explanation of a field. Use the field’s description.

Intent

Intent Use for
Info Neutral information worth noticing. The default.
Success Something completed as expected.
Warning Something needs attention before it becomes a problem.
Error Something failed or is blocked, with what to do about it.

Each intent has a fixed icon (info, check circle, warning, error) that cannot be changed: the icon and the title say the kind of message as well as the tint.

Title and message

The title states the point in a few words (Payment failed); it is the first thing announced. The message says what happened and what to do, in one or two plain sentences. A one-sentence message can stand without a title.

The alert has no close button and no actions in this version: dismissing needs script, and an action inside a live region is read before people can reach it. Both are open questions.

Content

  • Title: a few words, sentence case, no period. Message: one or two sentences, with a period.
  • Say the status in words, never through the color: Your card was declined, not Something went wrong.
  • With the error intent, say how to recover.

Accessibility

The Specification tab lists the full accessibility contract. Each statement there links the source it comes from. This section explains the decisions behind it.

Web

  • The implementation renders a <div role="alert">, an assertive and atomic live region, with the icon in aria-hidden="true". Insert it, or set its content, at the moment of the event (MDN: alert role, ARIA19, WAI-ARIA: aria-hidden).

Android

  • Mark alert-like components with the live region semantics so accessibility services announce them, and use the assertive mode sparingly (Jetpack Compose: alerts and pop-ups).
  • Badge (the status of one item)