# Sync Button

> A sync button whose arrows spin while it works, coast to a stop instead of halting, draw a check, and keep "Synced 3 min ago" up to date.

## Spec sheet

| | |
| --- | --- |
| Access | Free: no account, free for commercial use |
| Shelf | Components › State Changes |
| Live preview | https://uibrik.com/components/sync-button |
| Writes | 1 file into `components/uibrik/sync-button/` |
| Packages | `motion`, `react-use-measure` (the CLI installs them) |
| Needs | React 19, Tailwind CSS v4, a project set up with `npx shadcn@latest init` |
| Theme | Reads the shadcn tokens and follows class-based dark mode ([theming](https://uibrik.com/docs/theming.md)) |
| Updated | Nov 22, 2026 |

## Add it

```bash
npx shadcn@latest add https://uibrik.com/r/sync-button.json
```

With the `@uibrik` namespace in `components.json` ([setup](https://uibrik.com/docs/installation.md)): `npx shadcn@latest add @uibrik/sync-button`.

Can't run commands? https://uibrik.com/components/sync-button/prompt.txt has every file verbatim, with the setup steps, ready for an assistant to write.

## Render it

Renders as is; every value shown is the default, so delete any line you don't need.

```tsx
import { SyncButton } from "@/components/uibrik/sync-button/sync-button";

<SyncButton
  duration={1.6}
  label="Sync now"
  syncingLabel="Syncing"
  syncedLabel="Synced"
  successColor="#16a34a"
  errorColor="#dc2626"
  size="md"
  errorLabel="Couldn't sync"
  onSync={() => {}}
  // defaultLastSynced={…}
/>
```

## Tune it

The same props as the Customize panel on https://uibrik.com/components/sync-button.

| Prop | Type | Default | What it does |
| --- | --- | --- | --- |
| `duration` | `number` | `1.6` | How long a simulated sync takes. |
| `label` | `string` | `"Sync now"` | Label before the first sync. |
| `syncingLabel` | `string` | `"Syncing"` | Label while it works. |
| `syncedLabel` | `string` | `"Synced"` | Prefix for the time since the last sync. |
| `successColor` | `string` | `"#16a34a"` | Colour of the check. |
| `errorColor` | `string` | `"#dc2626"` | Colour of the error state. |
| `size` | `"sm" \| "md" \| "lg"` | `"md"` | Height, padding and text size. |

## Wire it

The props the Customize panel doesn't show: ranges, data, content and callbacks.

| Prop | Type | Default | What it does |
| --- | --- | --- | --- |
| `onSync` | `() => Promise<unknown> \| void` |  | Runs the sync. A returned promise keeps it spinning until it settles; a rejection shows the error. |
| `defaultLastSynced` | `Date \| number` |  | When the last sync happened, on mount. |
| `errorLabel` | `string` | `"Couldn't sync"` | Label after a failed sync. |
| `className` | `string` |  | Classes for the wrapper. |

## Where it fits

- **Integrations and data sources**: The time since the last sync stays current, so people know whether the numbers are fresh. Pairs with [MCP Connectors](https://uibrik.com/components/mcp-connectors.md) (Pro) and [Integration Box](https://uibrik.com/components/integration-box.md) (Pro).
- **Dashboards with manual refresh**: Arrows that coast to a stop make a fast refresh still feel like it did something. Pairs with [Revenue Dashboard](https://uibrik.com/components/revenue-dashboard.md) (Pro).
- **Offline-first apps**: Pass the real sync as a promise; a failure shakes the button and says so in red. Pairs with [Offline Plug](https://uibrik.com/components/offline-plug.md) (Pro).

## Same shelf: State Changes

- [Typing Dots](https://uibrik.com/components/typing-dots.md): A typing indicator whose bubble grows from three dots into the message itself, so the reply lands where the dots were.
- [Disabled Reason](https://uibrik.com/components/disabled-reason.md): A disabled button that answers a press: it shakes, says why it's blocked, and moves focus to the field that needs fixing.
- [Download Button](https://uibrik.com/components/download-button.md): A download button whose arrow drops into its tray, fills with progress as the percentage counts up, then draws a check and offers Open.
- [Follow Button](https://uibrik.com/components/follow-button.md): A follow button whose plus folds into a check as it turns to Following, and warns with Unfollow on hover before you undo it.
- [Live Kbd](https://uibrik.com/components/live-kbd.md): Shortcut keycaps that sink as you press the real keys, then fire the action, so people learn the shortcut by using it.
- [Mute Toggle](https://uibrik.com/components/mute-toggle.md): A sound toggle whose waves fold away one at a time before a slash cuts through the speaker, and come back in reverse.

## Ground rules

- Only the props above exist. To change anything else, edit the installed file.
- Keep the files in `components/uibrik/sync-button/` so the import paths keep resolving.
- The playbook for working with the whole library: https://uibrik.com/llms.txt
