# SaveIndicator

Keep the difference between saved, dirty, saving and failed visible.

- Family: Status, imported from `mizu-ui` or `mizu-ui/status`
- Docs: https://mizu.user64bit.world/components/save-indicator
- Source: https://github.com/0xuser64bit/mizu/blob/main/packages/mizu/src/status/Feedback.tsx

## Usage

```tsx
"use client";

import { useState } from "react";
import { SaveIndicator, SegmentedControl } from "mizu-ui";

export function Example() {
  const [state, setState] = useState<"saved" | "unsaved" | "saving" | "error">(
    "unsaved",
  );
  return (
    <div style={{ display: "grid", gap: 16, justifyItems: "start" }}>
      <SaveIndicator state={state} onRetry={() => setState("saving")} />
      <SegmentedControl
        label="Demo save state"
        value={state}
        onValueChange={(v) => setState(v as typeof state)}
        options={["saved", "unsaved", "saving", "error"].map((v) => ({
          value: v,
          label: v,
        }))}
      />
    </div>
  );
}
```

## Copy it with the shadcn CLI

```sh
npx shadcn@latest init 0xuser64bit/mizu/preset # once, where there is no components.json
npx shadcn@latest add 0xuser64bit/mizu/save-indicator 0xuser64bit/mizu/segmented-control
```

## Props

- `state`: `"saved" | "unsaved" | "saving" | "error"`. Actual persistence state supplied by your app.
- `onRetry`: `() => void`. Optional retry for a failed save.

## Accessibility

Changes are announced politely. The retry control appears only when it can recover a failure.

## Motion

CSS transitions explain state changes. Reduced motion removes travel.
