# Retry spin

An error you retry with a flick: the arrow spins while the request is out and coasts to rest when it settles.

Also called: retry button, animated retry.

Example: Retry with a flick. Press Retry and the arrow leaps into a spin that keeps turning while the request is out, then coasts to rest when it settles. Preview: https://chatcn.dev/preview/retry-spin-demo

Press Retry and the arrow is given a spin: it leaps forward and keeps turning while the request is out, never slower than a steady idle; when the request settles, friction takes over and it coasts to rest upright. The message line edits in place, from the error to Retrying to what comes next, and counts attempts from the second one.

## Installation

```bash
npx shadcn@latest add https://chatcn.dev/r/retry-spin.json
```

## Usage

```tsx
import { RetrySpin } from "@/components/ui/chatcn/retry-spin"

<RetrySpin status={status} attempt={attempt} message="The model is overloaded right now." onRetry={retry} />
```

## Examples

### States

Example: Failed, retrying, recovered. The error with its retry, then the second attempt spinning. Once it works the line clears itself. Preview: https://chatcn.dev/preview/retry-spin-states

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `status` | `"error" | "retrying" | "ok"` | Ok fades it away |
| `message` | `string` | What went wrong, and how to fix it |
| `onRetry` | `() => void` |  |
| `attempt` | `number` | From 2 the line says Attempt n |
| `retryingLabel` / `retryLabel` | `string` | Default Retrying and Retry |

## Accessibility

- `role="alert"`: the error is announced; the button is a plain labelled button.

## Motion

- The spin is a velocity with friction and an idle floor; the rest is a critically damped spring to the next upright turn.
- Reduced motion: no spin; the label still changes.

Source: https://chatcn.dev/docs/components/retry-spin