Toast
BetaFeedback and overlaysOpen in the workshop
A short, temporary confirmation of something that just happened.
.xg-toast-region > .xg-toast (--success --warning --error) · XG.toast({title, text, tone, action}) · [data-xg-toast='{…}']Example and markup
Live, from xg-ui.css and xg-ui.js. Switch the brand and mode on the example itself, or for the whole site in the header.
Markup
<div class="xg-row">
<button class="xg-btn xg-btn--secondary" type="button" data-xg-toast='{"title":"Campaign published","text":"Live in 4 markets.","tone":"success","action":"View"}'>Success toast</button>
<button class="xg-btn xg-btn--secondary" type="button" data-xg-toast='{"title":"Fraud share above 2%","text":"Two publishers were paused automatically.","tone":"warning"}'>Warning toast</button>
<button class="xg-btn xg-btn--secondary" type="button" data-xg-toast='{"title":"Export failed","text":"The file was larger than 1 GB. Narrow the date range.","tone":"error","timeout":0}'>Error toast</button>
</div>States
Hover, focus and pressed are forced here with .is-hover, .is-focus and .is-active so they can be seen side by side; in a product they come from :hover, :focus-visible and :active.
| State | Toast |
|---|---|
| Info | Report scheduled |
| Success | Campaign published |
| Warning | Fraud share above 2% |
| Error | Export failed |
Variants
Campaign published
Live in 4 markets.
Export failed
The file was larger than 1 GB.
Markup
<div class="xg-stack" style="gap:8px;align-items:flex-start">
<div class="xg-toast xg-toast--success" style="animation:none">
<span class="xg-toast__dot" aria-hidden="true">
</span>
<div class="xg-toast__body">
<p class="xg-toast__title">Campaign published</p>
<p>Live in 4 markets.</p>
</div>
</div>
<div class="xg-toast xg-toast--error" style="animation:none">
<span class="xg-toast__dot" aria-hidden="true">
</span>
<div class="xg-toast__body">
<p class="xg-toast__title">Export failed</p>
<p>The file was larger than 1 GB.</p>
<div class="xg-toast__action">
<button class="xg-btn xg-btn--ghost xg-btn--sm" type="button">Narrow the range</button>
</div>
</div>
</div>
</div>When to use it
Use it for
“Campaign published”, “Report exported”, an Undo after an action.
Not for
errors the user must act on (Alert or the field error); anything they need to read twice.
Rules
- Title in the past tense, under about 40 characters; optional one-line detail.
- Disappears after 5 s, stays while hovered; error toasts stay until dismissed.
- At most three on screen, newest at the bottom right.
- One action at most (Undo, View).
Accessibility
- The region is role="status" aria-live="polite"; toasts never take focus. Dismiss button has aria-label.
Every color pair this component uses is measured for both brands in light and dark on the Accessibility page.
Related
Also in Feedback and overlays: Modal, Alert dialog, Drawer, Alert, Popover. Used in the patterns Forms and overlays.
Status Beta: usable; class names may still change in a minor release, with a note (see Releasing).