Skip to content
Fleetline

Alert

Usage

Use an inline alert for a message about the content it sits next to that should stay visible until resolved: an overdue vehicle on its detail page, a failed import above the table, a confirmation after saving a form.

For brief confirmations that don't need to stay, use a toast. Content: title states what happened in ≤ 8 words; description says why and what to do; actions are verb + object ("Schedule service"). Don't make every alert dismissible: danger alerts stay until the problem is fixed.

Anatomy

  1. Container — .alert.alert--{tone}, tinted fill and a 4px inline-start bar
  2. Icon — svg.alert__icon, different shape per tone, aria-hidden
  3. Title — .alert__title
  4. Description — .alert__description
  5. Actions (optional) — .alert__actions
  6. Dismiss (optional) — .alert__dismiss icon button

Examples

Alert

Telematics sync every 15 minutes

Odometer readings on this page can be up to 15 minutes old.

Service plan saved

KX-24 is next due for a brake inspection at 104,000 km.

Vehicle KX-24 is overdue for service

Brake inspection was due at 84,000 km. It's now at 85,200 km.

We couldn't import 3 vehicles

Rows 4, 9 and 17 have no VIN. Add the VINs to the file and import it again.

Fuel report moved

Monthly fuel reports are now under Reports › Costs.

Vehicle KX-24 is overdue for service

Brake inspection is 1,200 km overdue. Book it before the next dispatch.

View service plan
<!-- Present at page load: no role -->
<div class="alert alert--warning">
  <svg class="alert__icon" aria-hidden="true" focusable="false"><use href="#icon-triangle-alert"></use></svg>
  <div class="alert__content">
    <p class="alert__title">Vehicle KX-24 is overdue for service</p>
    <p class="alert__description">Brake inspection is 1,200 km overdue.</p>
    <div class="alert__actions"><button type="button" class="btn btn--secondary btn--sm">Schedule service</button></div>
  </div>
</div>

<!-- Inserted after an action: role="status" (polite) or role="alert" (urgent errors) -->
<div class="alert alert--danger" role="alert">…</div>

<!-- Dismissible (js/alert.js) -->
<button type="button" class="btn btn--ghost btn--sm alert__dismiss" aria-label="Dismiss: Fuel report moved">…</button>

API

HookValuesPurpose
.alertblockContainer (info tone by default)
.alert--info | --success | --warning | --dangermodifierTone
.alert__icon | __content | __title | __description | __actions | __dismisspartsSee anatomy
role="status" | "alert"attributeOnly when inserted dynamically: polite / assertive announcement
data-alert-return="id"attribute on dismissWhere focus goes after dismissing (default: next focusable element)
alert:dismisseventFired on the alert so apps can remember the choice

Do and don't

We couldn't save WO-1042

The connection dropped. Your changes are kept — try again.

Do say what happened and how to fix it.

Error 500

Don't show codes without meaning, or rely on red alone to signal a problem.

Accessibility

Keyboard interaction
KeyBehavior
TabReaches actions and the dismiss button in reading order
Enter / Space on dismissHides the alert and moves focus to the next element, so focus isn't lost

Tokens

Custom propertyPurpose
--color-feedback-{info|success|warning|danger}-bgFill
--color-feedback-{tone}-fgText
--color-feedback-{tone}-borderBorder and inline-start bar
--color-feedback-{tone}-iconIcon
--radius-md, --space-1 | -3 | -4Shape, bar width, padding