Skip to main content

  • Foundations
    • Border radius
    • Breakpoints
    • Colours
    • Colour scheme
    • Elevation
    • Focus and outline
    • Sizing and spacing
    • Layout
    • Motion
    • Typography
    • Z-index
  • Elements
    • Buttons
    • Code
    • Icons
    • Figure and caption
    • Forms
    • Links
    • Lists
    • Media
    • Tables
  • Components
    • Accordion
    • Alerts
    • Avatar
    • Blockquote
    • Breadcrumbs
    • Card
    • Chiplets
    • Details and summary
    • Dialog
    • Empty state
    • Stats
    • Global footer
    • Horizontal rule
    • Kanban
    • Key-value list
    • Meter
    • Objects
    • Pagination
    • Polka background
    • Post-it note
    • Progress
    • Speech bubbles
    • Status dot
    • Skeleton
    • Skip link
    • Spinner
    • Toggles
    • Tooltip
    • Webmentions
  • Patterns
    • Article header
    • Author card
    • App list and app sheet
    • Error page
    • Related posts
    • Search results
    • Utilities

John Peart

  • Search
  • Menu
John Peart

Alerts

Inline status messages — info, success, warning, error.

Info

i

Heads up

The quick brown fox jumps over the lazy dog.

<div class="alert alert--info" role="status">
  <span class="alert--icon" aria-hidden="true">i</span>
  <div class="alert--body">
    <p class="alert--title">Heads up</p>
    <p>Message body goes here.</p>
  </div>
  <button type="button" class="alert--close" aria-label="Dismiss">
    {% include "components/icons/xmark.svg" %}
  </button>
</div>

Success

Saved

Your changes have been saved.

<div class="alert alert--success" role="status">
  <span class="alert--icon" aria-hidden="true">
    {% include "components/icons/checkmark.svg" %}
  </span>
  <div class="alert--body">
    <p class="alert--title">Saved</p>
    <p>Your changes have been saved.</p>
  </div>
  <button type="button" class="alert--close" aria-label="Dismiss">
    {% include "components/icons/xmark.svg" %}
  </button>
</div>

Warning

Check this

One of the fields looks unusual.

<div class="alert alert--warning" role="status">
  <span class="alert--icon" aria-hidden="true">
    {% include "components/icons/warning.svg" %}
  </span>
  <div class="alert--body">
    <p class="alert--title">Check this</p>
    <p>One of the fields looks unusual.</p>
  </div>
  <button type="button" class="alert--close" aria-label="Dismiss">
    {% include "components/icons/xmark.svg" %}
  </button>
</div>

Error

Something went wrong

We couldn't save your changes. Try again in a moment.

<div class="alert alert--error" role="alert">
  <span class="alert--icon" aria-hidden="true">
    {% include "components/icons/xmark.svg" %}
  </span>
  <div class="alert--body">
    <p class="alert--title">Something went wrong</p>
    <p>We couldn't save your changes. Try again in a moment.</p>
  </div>
  <button type="button" class="alert--close" aria-label="Dismiss">
    {% include "components/icons/xmark.svg" %}
  </button>
</div>

Alert region

For transient notifications, stack alerts inside an .alert-region container. It's fixed to the bottom-right of the viewport and animates each alert in.

<div class="alert-region" aria-live="polite">
  <div class="alert alert--success" role="status">
    <span class="alert--icon" aria-hidden="true">
      {% include "components/icons/checkmark.svg" %}
    </span>
    <div class="alert--body">
      <p class="alert--title">Saved</p>
      <p>Your changes are live.</p>
    </div>
    <button type="button" class="alert--close" aria-label="Dismiss">
      {% include "components/icons/xmark.svg" %}
    </button>
  </div>
</div>
A line drawing of John Peart

John Peart

www.johnpe.art

Mastodon logo

Mastodon

BlueSky logo

Bluesky

LinkedIn logo

LinkedIn

Github logo

GitHub