Skip to content
HomeCobalt

Save line

Says whether what a person edited is saved, in one line that never changes size: Saving, Saved, Not saved with Retry, Could not confirm with Check, or Changed elsewhere with Show latest.

Examples

A profile that saves as you type: one save after you pause, Saving only when it is slow, then Saved; with the Offline control on it says Not saved, and Retry sends it again.

Profile

StaleWhen someone saved a newer version elsewhere, the next save is refused and the line says Changed elsewhere; Show latest puts their version on screen, never a merge.
StatesEvery wording the line can say, each with its one way on; the line keeps the size of its longest, so a change of wording moves nothing.
Nothing sent yet
Shown on your profile
A save is out and slow
Saving
The server holds the last edit
SavedSaved
Refused, or the server was out of reach
Not savedNot saved
The answer to a save was lost
Could not confirmCould not confirm
Asking whether it landed
Checking
A newer version was saved elsewhere
Changed elsewhereChanged elsewhere
UnconfirmedA save whose answer was lost says Could not confirm and offers Check, never a blind Retry: Check asks the server what it holds, and only then does saving go on.

Usage

Use it when

  • A form that saves itself as it is edited: a profile, a note, a document's title.
  • A setting that saves on its own press, under its name, through SettingsRow's status.
  • A form that saves as a whole, beside its heading, from useSaveState(save.status).

Use something else when

  • A button the person waits beside. Use StateButton instead, which reports in the button.
  • A save the person cannot see the result of. Use Toaster instead.
  • A list's read. Use ListBody instead, which dims the rows.

Rules

General

Content

Avoid

Limits

Install

npx shadcn@latest add https://kaanarici.com/r/cobalt/save-line.json https://kaanarici.com/r/cobalt/use-autosave.json
import { SaveLine } from "@/components/cobalt/ui/save-line"
import { useAutosave, useSaveState, type SaveState } from "@/lib/cobalt/use-autosave"