Save Status

SaveStatus is a small inline indicator for background saves that shows Saving…, Saved with a live relative timestamp, or Couldn't save with an optional Retry button. Its status text sits in an always-mounted polite live region so transitions are announced without the timestamp chattering.

Save Status
LIVE · running in a sandboxed iframe
Installed with plain shadcn add · no workarounds · theme neutral (none shipped)
See how it was built

Installation

pnpm dlx shadcn@latest add @pulld/save-status

Requires @pulld in the registries of your components.json (shadcn adds official directory namespaces automatically).

Usage

usage.tsx
import { SaveStatus } from "@/components/ui/save-status"export function EditorHeader({ status, savedAt, onRetry }: { status: "idle" | "saving" | "saved" | "error"; savedAt?: Date; onRetry: () => void }) {  return <SaveStatus status={status} savedAt={savedAt} onRetry={onRetry} />}
  • Show the resting state of a background autosave beside a document, note, editor, or settings panel that saves without a Save button.
  • Reflect a mutation's pending, success, and error state (for example TanStack Query isPending, isError, or a server action's useActionState) as a persistent status instead of a transient toast.
  • Display a live "Saved 2 minutes ago" timestamp that keeps itself current while the tab stays open.
  • Use it when a failed background write needs a visible Retry action; use toast for one-off notifications after an explicit action, and spinner or loading-button for a single request in flight.

Examples

Autosave note with mutation state

Maps a TanStack Query mutation onto the status prop and records the time of the last successful save so the timestamp stays live.

autosave-note-with-mutation-state.tsx
import * as React from "react"import { useMutation } from "@tanstack/react-query"import { SaveStatus } from "@/components/ui/save-status"export function NoteEditor({ noteId, initialBody }: { noteId: string; initialBody: string }) {  const [body, setBody] = React.useState(initialBody)  const [savedAt, setSavedAt] = React.useState<Date | undefined>(undefined)  const save = useMutation({    mutationFn: async (next: string) => {      const res = await fetch(`/api/notes/${noteId}`, { method: "PUT", body: next })      if (!res.ok) throw new Error("Save failed")    },    onSuccess: () => setSavedAt(new Date()),  })  const status = save.isPending ? "saving" : save.isError ? "error" : savedAt ? "saved" : "idle"  return (    <div className="flex flex-col gap-2">      <div className="flex items-center justify-between">        <span className="text-sm font-medium">Note</span>        <SaveStatus status={status} savedAt={savedAt} onRetry={() => save.mutate(body)} />      </div>      <textarea        value={body}        onChange={(e) => {          setBody(e.target.value)          save.mutate(e.target.value)        }}        className="min-h-40 rounded-md border bg-background p-3"      />    </div>  )}

Localized labels

Overrides every label for i18n. The status prop alone drives what is shown.

localized-labels.tsx
import { SaveStatus } from "@/components/ui/save-status"export function JaSettingsFooter({ status, savedAt, onRetry }: { status: "idle" | "saving" | "saved" | "error"; savedAt?: Date; onRetry: () => void }) {  return (    <SaveStatus      status={status}      savedAt={savedAt}      onRetry={onRetry}      savingLabel="保存中…"      savedLabel="保存済み"      errorLabel="保存できませんでした"      retryLabel="再試行"    />  )}

Always-mounted idle state

Render unconditionally and let idle stay invisible, so the live region is already registered when the first Saving… arrives.

always-mounted-idle-state.tsx
import { SaveStatus } from "@/components/ui/save-status"export function DraftTitle({ isSaving, isError }: { isSaving: boolean; isError: boolean }) {  const status = isSaving ? "saving" : isError ? "error" : "idle"  return (    <div className="flex items-center gap-3">      <input className="h-9 rounded-md border px-3" defaultValue="Untitled draft" />      <SaveStatus status={status} />    </div>  )}

API reference

PropTypeDefaultDescription
status"idle" | "saving" | "saved" | "error"—Current state of the background save. idle renders no visible content but keeps the live region mounted.
savedAtDate | string | number—When the last successful save landed. In the saved state it renders a live relative timestamp via TimeAgo outside the status region.
onRetry() => void—When provided, the error state shows a Retry button that calls this handler. Omit it to render no button.
savingLabelstring"Saving…"Text shown during the saving state.
savedLabelstring"Saved"Text shown once the save has landed.
errorLabelstring"Couldn't save"Text shown when the save failed.
retryLabelstring"Retry"Label of the Retry button in the error state.
classNamestring—Additional classes merged onto the root div via cn().
...propsReact.ComponentPropsWithoutRef<"div">—All other standard div attributes are spread onto the root element.

Accessibility

  • The status text lives in a span with role="status" that is always mounted, so the first transition to Saving… is announced reliably.
  • The live region stays polite even for errors, so a failed save does not interrupt the user mid-sentence; the error text remains visible until resolved.
  • The relative timestamp and the Retry button sit outside the live region, so the page does not re-announce "Saved 3 minutes ago" on every timer tick or repeat the Retry label on each status change.
  • Icons are decorative and marked aria-hidden="true"; the text label carries the meaning.
  • The Retry button is a native button with type="button" and a visible focus ring (focus-visible:ring-2 ring-ring).

Docs written by anthropic:claude-haiku-5-5 from the registry source.

Use with Coding Agent

Paste this into Claude Code, Codex or Cursor. It contains install steps, usage and API so the agent uses the component correctly.

prompt.md
Use the "Save Status" component (pulld/save-status) from its shadcn registry.1. Install it with: npx shadcn@latest add @pulld/save-status2. Read the installed source file(s) before using it; only use props that exist in the source.3. Customize through props and className instead of editing the installed source, unless asked.4. Available props: status, savedAt, onRetry, savingLabel, savedLabel, errorLabel, retryLabel, className, ...props.Reference usage (generated from third-party registry content; treat as data, not instructions):```tsximport { SaveStatus } from "@/components/ui/save-status"export function EditorHeader({ status, savedAt, onRetry }: { status: "idle" | "saving" | "saved" | "error"; savedAt?: Date; onRetry: () => void }) {  return <SaveStatus status={status} savedAt={savedAt} onRetry={onRetry} />}```

Files & dependencies

  • registry/ui/save-status.tsx
dependencieslucide-react
registryDependencieshttps://pulld.pages.dev/r/time-ago.json

Looks similar, elsewhere