Alert
A message about what just happened or needs attention, in four tones. Urgent ones interrupt; the rest wait their turn.
Try it
Heads up
Your plan renews on December 1.
All set
Your changes are live.
Check this
Two images are missing alt text.
The error appears when something goes wrong, so screen readers read it at once. The others wait for a pause.
Code
Plain HTML for any site, or React. Both use the same styles, so the alert looks the same wherever it lands.
ReadyAny website, Shopify, WordPress, Square, plain hosting
<link rel="stylesheet" href="tokens.css">
<link rel="stylesheet" href="base.css">
<link rel="stylesheet" href="composites.css">
<!-- Alert: tone shown by icon, title, and color together.
Info and success use role="status": read when there is a pause.
Warning and error use role="alert": read at once. Use them only when it matters now. -->
<section class="prism-composite prism-callout prism-callout--error" role="alert">
<span class="prism-callout__icon"><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" aria-hidden="true"><circle cx="12" cy="12" r="9"/><path d="M9 9l6 6M15 9l-6 6" stroke-linecap="round"/></svg></span>
<div class="prism-callout__body">
<h3 class="prism-callout__title">Payment failed</h3>
<p class="prism-callout__text">Your card was declined. Update it to keep your site online.</p>
<div class="prism-callout__actions"><a class="prism-btn prism-btn--secondary" href="/billing">Update card</a></div>
</div>
<button type="button" class="prism-callout__close" aria-label="Dismiss: Payment failed">×</button>
</section>
<!-- Tones: prism-callout--info, --success, --warning, --error.
For role="alert" to be read, add the alert to the page when the problem happens, not at page load. -->Accessibility
- Each tone shows an icon, a title, and a colored edge together, so it never rests on color.
- Info and success are polite: read when there is a pause. Warning and error interrupt, so use them only when it matters now.
- An urgent alert is added when the problem happens. One that is there at page load is not announced.
- Alerts never vanish on a timer. People close them with a button that names the alert.
- Focus is not moved to an alert. If people must act, the action sits inside it.
- The error tone uses the same AA checked status color as every Prism theme.