Skip to content
Sign upGet access
MicrointeractionsCooldown ringMenu

Cooldown ring

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

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

$ pnpm dlx 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

PropTypeNotes
untilnumberWhen the wait ends, in ms since the epoch
totalnumberThe wait's full length in ms
onRetry() => voidPressed after the wait
readyLabelstringDefault "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.