VisorVisor
ComponentsFeedback

SaveStatus

Autosave readout — Saved / Saving / Syncing / Unsaved / Couldn't save in a fixed-width slot that never reflows its row, with a retry mark after a failed save. aria-live polite; draws no edge.

npx visor add save-status use-autosave

With useAutosave

SaveStatus is the readout for useAutosave: pass it the hook's status, and its retry for the retry mark. There is no Save button.

Saved
Type to autosave. Clear the field to see a refused value; type “fail” to see a failed save and retry.

Every state, in a row

The slot is sized from content: as wide as the longest label (overrides through labels count) in the theme's own font, plus room for the retry mark, so it is one width in every state and never clips a default label. --save-status-width pins it instead. So the text after it stays put as the state changes. Saved rests muted; Syncing is for a first sync from an outside source writing rows the user did not type: the consumer sets it, useAutosave never emits it, and its ink is --save-status-syncing-color. unsavedAs="dot" draws Unsaved as a dot alone; the slot does not change. Couldn't save takes the error colour and, when onRetry is passed, a retry mark.

BioSavedEdit history
BioSavingEdit history
BioSyncingEdit history
BioUnsavedEdit history
BioCouldn't saveEdit history
BioUnsavedEdit history

Accessibility

The label sits in a role="status" region with aria-live="polite", so a screen reader hears each change without losing its place. With unsavedAs="dot" the dot is decorative and the labels.unsaved text stays in the live region, visually hidden, so it is the dot's accessible name and is still announced. No state is carried by colour alone. The readout is status text, not a button: the only control is the retry mark (named "Retry saving"; set retryLabel to change it), and it sits outside the live region so it is not announced with every state.

Theming

components.save-status sets the slot: width, syncing-color, font-size, dot-size, unsaved-dot-size, font-family, text-transform and letter-spacing. Unset, the readout inherits its family, case and tracking from its row, and any rule of yours wins. A 78px caps mono readout:

components:
  save-status:
    width: "78px"
    font-family: "var(--font-mono)"
    text-transform: uppercase
    letter-spacing: "0.06em"

dot draws a status dot before the label in every state, in the state's ink. dot-size sets it, and unsaved-dot-size sets it while Unsaved (it follows dot-size until set). The dot's box is as wide as the larger of the two, so the label never moves. A 9px readout with a 5px dot that grows to 6px while unsaved:

components:
  save-status:
    font-size: "9px"
    dot-size: "5px"
    unsaved-dot-size: "6px"
<SaveStatus status={status} dot />

The retry mark is the icon Button's mark: --button-icon-size, --button-icon-pad (its hit target, which adds no height) and --button-icon-ghost-color. SaveStatus draws no edge, so there is nothing for control.edge-width to turn off.

Installation

npx visor add save-status

This copies two files into your project:

  • components/ui/save-status/save-status.tsx: the component
  • components/ui/save-status/save-status.module.css: the styles

API Reference

SaveStatusProps

PropTypeDefaultDescription
status*'saved' | 'saving' | 'syncing' | 'unsaved' | 'refused'—Where the value stands — pass `useAutosave(...).status`. `syncing` is the consumer's to set (a first sync from an outside source); `useAutosave` never emits it.
onRetry() => void—Shows a retry mark while `status` is `refused`. Pass `useAutosave(...).retry`.
labelsPartial<Record<'saved' | 'saving' | 'syncing' | 'unsaved' | 'refused', string>>—Override any of the five labels (Saved, Saving, Syncing, Unsaved, Couldn't save), e.g. to translate them. With `unsavedAs="dot"` the Unsaved label is the dot's accessible name.
unsavedAs'text' | 'dot''text'How `unsaved` is drawn. `dot` draws a dot alone with the label kept as visually hidden text, still announced by the live region. The slot width does not change.
dotbooleanfalseDraws a status dot before the label in every state, in the state's ink. With `unsavedAs="dot"`, Unsaved is this dot alone. The label never moves.
retryLabelstring'Retry saving'Accessible name of the retry mark.

SaveStatus also accepts the standard <span> HTML attributes.