# Cooldown ring

A rate limit you can watch run out: a ring drains round the seconds left and turns into Send again at zero.

Also called: rate limit countdown, resend timer.

Example: A limit you can watch run out. The rate limit drains round the seconds left; at zero the ring closes, the arrow turns in and the button opens to Send again. Preview: https://chatcn.dev/preview/cooldown-ring-demo

While the wait lasts the button is a ring draining round the seconds left. At zero the ring closes, the seconds give way to the retry arrow turning in, and the button opens to say Send again. It keeps its own clock against a timestamp, so a tab left in the background is right when you come back.

## Installation

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

## Usage

```tsx
import { CooldownRing } from "@/components/ui/chatcn/cooldown-ring"

<CooldownRing until={resetsAt} total={60_000} onRetry={send} />
```

## Props

| Prop | Type | Notes |
| --- | --- | --- |
| `until` | `number` | When the wait ends, in ms since the epoch |
| `total` | `number` | The wait's full length in ms |
| `onRetry` | `() => void` | Pressed after the wait |
| `readyLabel` | `string` | Default "Send again" |

## Accessibility

- During the wait the button is `aria-disabled` and named with the seconds left; ready, it is named Send again.

## Motion

- The ring is `stroke-dashoffset` on one circle; the label opens on `grid-template-columns`. The number re-renders once a second.

Source: https://chatcn.dev/docs/components/cooldown-ring