Skip to the page
Tactile UI

Kit part · Badges & tags

Sync status

A small legend that says whether your work is safe: Saving, Saved or Offline, with a lamp that matches (amber and blinking while it saves, green when it has, red when it cannot). The words are the state and the lamp only agrees with them. It is a polite status region, so changing its words is what a screen reader hears.

Element
<span class="tui-sync" role="status" data-state>
Needs
kit.css
Rules
sync-status.rules.md · 5
Finishes
Aluminium · Graphite · Oak · Walnut · Porcelain · Black · Daylight · Night · Paper · Phosphor · E-paper · AMOLED
Volumes
Tactile · Quiet
On this page
  1. Variants
  2. Every state, at once
  3. API
  4. Markup
  5. Accessibility
  6. How it’s built
  7. Rules
  8. Related parts

Seats open in 11 days. Want one email that morning?

Variants

Saving…
Saving · amber, blinking
Saved
Saved · green
Offline
Offline · red
Saved 2 min agoOffline changes kept on this device
With small print
SettingsSaved
In the head of a panel

Every state, at once

Both finishes, side by side. Hover, pressed and focus are forced with .is-hover, .is-down and .is-focus; checked and disabled are real.

Aluminium

PartSavingSavedOffline
LegendSaving… Saved 2 min agoOffline

Graphite

PartSavingSavedOffline
LegendSaving… Saved 2 min agoOffline

API

NameKindValuesWhat it does
span.tui-sync[role="status"][data-state]elementsaving · saved · offlineThe legend. data-state sets the lamp’s colour and, for saving, its blink. A polite status region.
.tui-lamp[data-on][aria-hidden="true"]elementthe kit’s lampThe lamp. Do not set data-lamp: the legend gives it its colour from data-state.
.tui-sync__text · .tui-sync__detailelementthe words · small printThe state in one word, and anything more after it: “2 min ago”, “changes kept on this device”.
syncText(state)functionpureThe words for a state: “Saving…”, “Saved”, “Offline”.
setSync(el, state, detail?)functionneeds kit.mjsChanges data-state and the words together, and does nothing if neither has changed, so the same words are not said twice.

Markup

<span class="tui-sync" role="status" data-state="saved">
  <span class="tui-lamp" data-on aria-hidden="true"></span>
  <span class="tui-sync__text">Saved</span>
  <span class="tui-sync__detail">2 min ago</span>
</span>

<!-- Change data-state to "saving" or "offline" and the words with it. -->
import { setSync, syncText } from '/kit/kit.mjs';

const legend = document.querySelector('.tui-sync');
setSync(legend, 'saving');                     // lamp amber and blinking, "Saving…"
await save();
setSync(legend, 'saved', 'just now');          // lamp green, "Saved just now"
setSync(legend, 'offline', 'changes kept on this device');

syncText('offline');                            // 'Offline'

Needs kit.css only, no script. How to install the kit.

Accessibility

  • It is role="status", a polite live region, so a screen reader says “Saving…”, then “Saved”, as the words change, without moving the focus or interrupting what it is reading.
  • The state is the word. The lamp is hidden from a screen reader and agrees with the words; amber, green and red are never the only sign, and the three words differ in their first letter and length.
  • The blink while it saves is the kit’s lamp blink, 1.2 seconds a step; it stops under reduced motion and the lamp stays lit amber.
  • Say Saved only when the work is kept, and Offline as soon as it cannot be. The words are the primary ink and the small print the secondary, both above 4.5:1 on the plate.
  • It is not a control and takes no focus; on a phone it is the same size and sits in the line of the thing it describes.

How it’s built

The status line the kit already has, with its lamp, drawn as a legend whose colour comes from one attribute. The lamp is the kit’s own, so every finish draws it as it draws any lamp, and the blink for saving is the lamp’s own blink. The words are changed by the page, and the script does no more than change the attribute and the words together.

Rules

sync-status.rules.mdIn the brain

Tell someone their work is being kept: three words and a lamp in the head of a document or the foot of a form.

5 rules in this file, with the foundations they rest on and the anti-patterns that break them. Full rules ship in the brain with the Pass.

OnlineIn review

Status

A lamp with words: the state line in tables, panel heads and lists. The words carry the meaning; the lamp is the glance.

Lamp

The only colour in the kit: a lamp that is on. Green is on, amber is waiting, red is recording or failing, blue is linked, white is standing by. Always next to words.

Preset saved.

Toast

A confirmation after an action: a small plate with a lamp and one factual sentence, read out politely, gone in 3.6 seconds.

Importing

Spinner

A ring of eight lamps lit in turn, a chase round a dial: each lamp is a dim cap with its light laid over it, and the light fades as the chase passes on, leaving a short tail. Only the light’s opacity moves. Amber, the lamp for work in hand. Under reduced motion it holds still on one lit lamp at the top, and the words still say it is busy.