AutosaveStatus
Says whether what the person writes is being saved by itself. It is quiet while it works and only asks for attention when saving fails, with a way to try again.
import { AutosaveStatus } from '@sypnia/ui/react'
Saving as you write
Write in the note and stop; write «fail» to see a failed save.
Saved at 11:40 AM
Code
import { useEffect, useRef, useState } from 'react';
import { AutosaveStatus, Field, Textarea, type AutosaveState } from '@sypnia/ui/react';
// Write in the note: a second after you stop, it saves by itself. Write «fail» to see what a failed save says.
export default function States() {
const [text, setText] = useState('Daily export to the finance bucket.');
const [state, setState] = useState<AutosaveState>('saved');
const [at, setAt] = useState(() => new Date());
const timer = useRef<ReturnType<typeof setTimeout>>(undefined);
const save = (v: string) => {
setState('saving');
setTimeout(() => { if (v.includes('fail')) setState('error'); else { setState('saved'); setAt(new Date()); } }, 900);
};
useEffect(() => () => clearTimeout(timer.current), []);
return (
<div className="sy-stack">
<Field label="Note for the team">
<Textarea value={text} onChange={(e) => { const v = e.target.value; setText(v); setState('idle'); clearTimeout(timer.current); timer.current = setTimeout(() => save(v), 1000); }} />
</Field>
<AutosaveStatus state={state} savedAt={at} onRetry={() => save(text.replace('fail', ''))} />
</div>
);
} Each state
Saving…
Saved at 9:41 AM
Not saved
Code
import { AutosaveStatus } from '@sypnia/ui/react';
// Each state on its own. Nothing shows while idle.
export default function AllStates() {
return (
<div className="sy-row">
<AutosaveStatus state="saving" />
<AutosaveStatus state="saved" savedAt={new Date('2026-11-17T09:41:00')} />
<AutosaveStatus state="error" onRetry={() => {}} />
</div>
);
} When to use it
Use it when
- Editors and notes that save as you type.
- Pass
savedAtso it says when the last save happened.
Do not use it when
- Forms saved with a button: the button shows its own state.
- Saving that never fails: say nothing.
For everyone
- It is a polite status: changes are read without interrupting.
- Every state is in words, not only an icon or a colour.
Props
| AutosaveStatus | Type | Default |
|---|---|---|
staterequired | "error" | "idle" | "saving" | "saved" | |
onRetry | (() => void) | |
savedAt | string | number | Date |