+234 Design System

Toast

A short message about something that just happened. Thirteen files currently roll their own live region.

The three kinds

✓ Saved to your account
⚠ Could not save. Check your connection and try again.
— Link copied
HTML
<div style="position:relative;display:flex;flex-direction:column;gap:var(--p234-space-3);max-width:26rem">
  <div class="p234-toast p234-toast--success">
    <span class="p234-toast__mark">&#10003;</span>
    <span>Saved to your account</span>
    <button class="p234-toast__action" type="button">Undo</button>
  </div>
  <div class="p234-toast p234-toast--error">
    <span class="p234-toast__mark">&#9888;</span>
    <span>Could not save. Check your connection and try again.</span>
    <button class="p234-toast__action" type="button">Retry</button>
  </div>
  <div class="p234-toast">
    <span class="p234-toast__mark">&#8212;</span>
    <span>Link copied</span>
  </div>
</div>

It must be announced

A toast nobody can see is a toast nobody gets. The container is a live region, so the message reaches a screen reader as well as the screen.

<div class="p234-toast-region" role="status" aria-live="polite">
  <!-- toasts are inserted here -->
</div>

Use aria-live="polite" for confirmations and role="alert" for failures, which interrupts. The region exists in the page from the start: inserting the region and the message together often means the message is never announced.

Rules

Where it is used

Save and follow, copy link, newsletter signup, and failures from any of those. These are the small confirmations that make the account features feel like they worked, which matters when retention is the problem being solved.

Tokens this component reads

--p234-color-paper-dark--p234-color-ink-inverse--p234-color-data-up--p234-color-data-down--p234-z-toast--p234-shadow-overlay--p234-radius-md--p234-type-ui-*--p234-space-3--p234-space-4--p234-space-5--p234-layout-gutter