domestic-ui GitHub

Alerts

Status messages, from notices in the page to live alerts and toasts.

Where alerts are used An alert is a notice at the top of the content area under the heading, and a toast appears in the bottom corner at the end of the window.

Live example

Inline alerts

<div class="stack">
  <div data-alert="info">
    <p><strong>Info:</strong> Maintenance is planned for Sunday at 02:00.</p>
  </div>
  <div data-alert="success">
    <p><strong>Success:</strong> Your changes were published.</p>
  </div>
  <div data-alert="warning">
    <p><strong>Warning:</strong> Your trial ends in 3 days.</p>
    <p><a href="#inline-title">Choose a plan</a> to keep your projects.</p>
  </div>
  <div data-alert="danger">
    <p><strong>Error:</strong> The file could not be uploaded. Try a file under 10 MB.</p>
  </div>
</div>

Live regions

<div class="cluster">
  <button type="button" data-announce="live-status">Save settings</button>
  <button type="button" data-announce="live-alert">Send without a subject</button>
</div>
<div id="live-status" role="status"></div>
<div id="live-alert" role="alert"></div>

Toasts

<div class="cluster">
  <button type="button" data-toast="success">Copy link</button>
  <button type="button" data-toast="info">Start export</button>
  <button type="button" data-toast="danger">Sync now</button>
</div>

Attributes

Attribute or valueEffect
data-alert="info | success | warning | danger"an inline alert with a tone
<dui-toaster role="status">the toast region (fixed position)
<button> as a toast's last childits dismiss button
role="status" | role="alert"native ARIA live regions

Toasts

A fixed <dui-toaster> region, whose web component (web-components/dui-toaster.js) adds a show() method and dismiss buttons. The region is role="status" and in the page from the start. Each toast has a Dismiss button. A toast is a status, not a dialog: it never takes focus. See explainers/toast.md.

Motion

A new toast fades in and lifts by --dui-motion-distance over --dui-motion-duration-normal; reduced motion keeps the fade only. Inline alerts and live region text appear at once: they are essential feedback.

Keyboard

KeyAction
Tabreaches each toast's Dismiss button; toasts never take focus
Enter / Spaceon Dismiss, removes the toast and focuses the next one

Accessibility

  • New messages are announced without moving focus (WCAG 4.1.3): role="status" is polite, role="alert" interrupts. Static alerts need no role.
  • Render the empty live region with the page and insert the text later (ARIA22, ARIA19).
  • Start the message with a word such as "Warning:", so tone is not color alone (WCAG 1.4.1).
  • Our choice: toasts never dismiss themselves or take focus, so nobody loses a message (WCAG 2.2.1).

Specifications

See also

How other systems do it

For comparison only; these are not the standard this system follows.

Search