Toast

Notifications that behave like modals' little sibling: top layer, fading in and out, responsive width – and still zero JavaScript.

Description

.toast is a fixed panel in the top right corner with the strongest elevation. Its width adapts per breakpoint (30vw up to 80vw), and it fades in and out via @starting-style transitions when opened and closed through the Popover API.

Declarative opening with popovertarget, Esc and light dismiss for free, and a consistent overlay language shared with modal and off-canvas. The status utilities (.color-success, .color-danger…) tint the message without extra classes on the panel.

Position and spacing use $gutter; elevation and radius come from the shared tokens, and the responsive widths can be overridden per breakpoint. The .btn-contrast button automatically keeps contrast against the panel color.

Toast

The trigger only needs popovertarget; a plain popover attribute gives the toast light dismiss and Esc closing for free. The close button uses .btn-contrast to stay readable over the panel.

Project saved.

HTML
<button popovertarget="saved-toast">Save</button>

<div id="saved-toast" popover class="toast">
  <div class="flex-row flex-full">
    <p><strong>Project saved.</strong></p>
    <button popovertarget="saved-toast" class="sm btn-contrast" aria-label="Close">X</button>
  </div>
</div>

Status toasts

The status utilities .color-success and .color-danger tint only the message text, with no extra classes on the panel itself. Any other status color (.color-info, .color-warning) works the same way.

Project saved.

Could not delete the project.

HTML
<div class="flex-row" style="align-items: center">
  <button popovertarget="toast-ok">Save</button>
  <button class="secondary" popovertarget="toast-err">Delete</button>
</div>

<div id="toast-ok" popover class="toast">
  <div class="flex-row flex-full">
    <p><strong class="color-success">Project saved.</strong></p>
    <button popovertarget="toast-ok" class="sm btn-contrast" aria-label="Close">X</button>
  </div>
</div>

<div id="toast-err" popover class="toast">
  <div class="flex-row flex-full">
    <p><strong class="color-danger">Could not delete the project.</strong></p>
    <button popovertarget="toast-err" class="sm btn-contrast" aria-label="Close">X</button>
  </div>
</div>