Skip to content

Save State

Autosave status for the header of an editor. It says whether the edits are saving, saved and how long ago, failed with a Retry, waiting offline, or changed by someone else with Review, Keep mine and Keep theirs. You run the save; it shows the state you pass.

On this page
Used for
  • Prompt editor header
  • Agent instructions
  • Doc and note editors
  • Settings that save on change
  • Offline-first forms

Examples

State
Look
Size

Autosave as you type

Edited elsewhere

Installation

npx knowns-ui@latest add save-state
For Claude Code, Cursor or Codex: installs it and wires the props to your own data.

Props

state
"idle" | "saving" | "saved" | "failed" | "offline" | "conflict"
What happened to the edits. Controlled.
lastSavedAt
number | Date
When the last save landed: Saved 2m ago, and Last saved 2m ago on a failure. Idle with a time reads Saved.
now
number
DefaultDate.now()
Fixes the clock for tests and screenshots. Without it the time refreshes every 30s.
queued
number
Default0
Edits waiting while offline: 3 edits will save when back online.
error
ReactNode
Why the save failed, in the Retry tooltip.
conflictBy
string
Who changed it elsewhere: Edited elsewhere by Mai Tran.
onRetry
() => void
Shows Retry on a failure.
onReview
() => void
Shows Review on a conflict, to open a compare view.
onResolve
(choice: "mine" | "theirs") => void
Shows Keep mine and Keep theirs on a conflict.
variant
"inline" | "pill"
Default"inline"
Text in a header row, or the status on a hairline pill with the actions beside it.
size
"sm" | "md"
Default"md"
12 or 12.5px text; the actions are 24 or 28px buttons.

Accessibility

  • The icon and the label sit in a polite status region, so a change of state is read once. The time after it is outside the region, so it does not speak every 30 seconds.
  • The icons are decorative. Each state also has words, so colour is never the only signal.
  • Retry, Review, Keep mine and Keep theirs are buttons you reach with Tab. Retry shows its reason on focus as well as on hover.
  • With reduced motion the check, the shake and the label rise are gone and the state changes at once.

What it handles

  1. 01Says what happened to the edits in six states: no changes yet, saving, saved with how long ago, could not save, offline and edited elsewhere.
  2. 02Keeps the time fresh (Saved 2m ago, 3h ago, yesterday) every 30 seconds without saying it again to a screen reader.
  3. 03Offers Retry on a failure, with the reason in its tooltip, and Review, Keep mine and Keep theirs on a conflict, each through your callback.
  4. 04Counts the edits that wait while offline: 3 edits will save when back online.
  5. 05Sits as plain text in a header row, or on a hairline pill, in two sizes.
  6. 06Stays controlled: you own the save, it only shows the state you pass.

States

First render
The state paints as it is, nothing plays
none
Saving and saved while typing
The words crossfade, the check is still
120ms opacity, ease out
Other label changes
The new words settle with a 4px rise
180ms, ease out
Saved after a failure, offline or a conflict
The check draws
180ms, ease out
Saving to failed
The mark shakes once and its X draws
280ms shake, 180ms draw
Edited elsewhere
The mark pulses once
180ms, ease out
Time passes
The time text changes in place
none
Reduced motion
States change at once
0ms

Works with

When to use

When to use

  • Telling people whether their edits in a prompt, doc or settings editor are saved, still saving, failed, waiting offline or changed by someone else.
  • An autosave form or editor header where a Save button would be one step too many.

When not to use

  • A save that needs a full message and an action, such as a lost session: use Toast.
  • The live state of an agent or a run: use Status Dot.

Using with AI

Use Copy page for AI above to give your assistant this page, Copy prompt under the install command to have it installed and wired to your data, or connect the Knowns UI MCP server and just ask:

  • Add the Knowns UI Save State to my app and wire it to my own data.
  • I need telling people whether their edits in a prompt, doc or settings editor are saved, still saving, failed, waiting offline or changed by someone else. Set that up with the Knowns UI Save State.
  • Which Save State props do I need for a minimal setup? Show me a short example.

With the server connected, your assistant calls get_component({ name: "save-state" }) and search_docs({ query: "save state" }).

Need help?

Stuck on Save State, or found something off? We read every message.