Alert
BetaFeedback and overlaysOpen in the workshop
A message that stays on the page until its cause is resolved.
.xg-alert (--success --warning --error, none = info) > .xg-alert__icon + .xg-alert__body (.xg-alert__title + p) + optional actionExample 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.
Reports update every 15 minutes
Today’s numbers are an estimate until 06:00 UTC.
Demand partner connected
Partner 2 is receiving requests.
Limited by budget
This campaign spent its daily budget by 14:00 UTC. Raise the budget
Payment method declined
Update it by Dec 5 to keep campaigns running.
Markup
<div class="xg-stack" style="gap:12px">
<div class="xg-alert" role="status">
<span class="xg-alert__icon" aria-hidden="true">i</span>
<div class="xg-alert__body">
<p class="xg-alert__title">Reports update every 15 minutes</p>
<p>Today’s numbers are an estimate until 06:00 UTC.</p>
</div>
</div>
<div class="xg-alert xg-alert--success" role="status">
<span class="xg-alert__icon" aria-hidden="true">✓</span>
<div class="xg-alert__body">
<p class="xg-alert__title">Demand partner connected</p>
<p>Partner 2 is receiving requests.</p>
</div>
</div>
<div class="xg-alert xg-alert--warning" role="status">
<span class="xg-alert__icon" aria-hidden="true">!</span>
<div class="xg-alert__body">
<p class="xg-alert__title">Limited by budget</p>
<p>This campaign spent its daily budget by 14:00 UTC. <a class="xg-link" href="#">Raise the budget</a>
</p>
</div>
</div>
<div class="xg-alert xg-alert--error" role="alert">
<span class="xg-alert__icon" aria-hidden="true">!</span>
<div class="xg-alert__body">
<p class="xg-alert__title">Payment method declined</p>
<p>Update it by Dec 5 to keep campaigns running.</p>
</div>
<button class="xg-btn xg-btn--secondary xg-btn--sm" type="button">Update</button>
</div>
</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 | Alert |
|---|---|
| Info | Reports update every 15 minutes |
| Success | Partner connected |
| Warning | Limited by budget |
| Error | Payment declined |
When to use it
Use it for
account or campaign conditions: payment method expiring, campaign limited by budget, sandbox mode.
Not for
transient confirmations (Toast); field validation (field error).
Rules
- Title says the condition; the line says the fix, with a link or button.
- Place it above what it concerns, not at the top of every page.
Accessibility
- role="status" for info and success; role="alert" only for errors that appear after an action.
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, Toast, Popover. Used in the patterns Dashboard, Onboarding and sign-up, Loading, empty and error states.
Status Beta: usable; class names may still change in a minor release, with a note (see Releasing).