Cooldown ring
A rate limit you can watch run out: a ring drains round the seconds left and turns into Send again at zero.
On this page
The rate limit drains round the seconds left; at zero the ring closes, the arrow turns in and the button opens to Send again.
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
Usage
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-disabledand named with the seconds left; ready, it is named Send again.
Motion
- The ring is
stroke-dashoffseton one circle; the label opens ongrid-template-columns. The number re-renders once a second.