Skip to content

No.26 · Buttons

Cooldown Button

“Resend code” with the wait drawn on its border: the outline drains clockwise as a timer, then closes, glows once and the button is ready.

The prompt

Copy this text

Automatic copying is unavailable. Copy the selected text using your device’s copy command.

Written for the variant you picked above: Night

Build a 'Resend code' button for a verification screen whose border is the cooldown timer. From the measured size, draw a pill outline in SVG starting at the top centre and running clockwise, twice: a faint track, and an accent arc with pathLength=1. Every animation frame, with rem = time left ÷ total, set the arc's stroke-dasharray to 'rem 1' and its dashoffset to −(1 − rem), so it drains clockwise from the top. The label ticks once a second ('Resend code in 0:24', tabular figures) and the button is aria-disabled with an accessible label that gives the seconds left. At zero the arc becomes a closed ring in green, a copy of it glows and fades once (900ms), the label reads 'Resend code' and a polite live region says it's available. Pressing it then calls onResend, announces 'New code sent to +968 9••• 4412' and starts the wait again. Selected variant — Night (night): Palette for this theme (Night): --cdb-arc #b9cce4; --cdb-face #141317; --cdb-ink #efe8dc; --cdb-muted #8f8994; --cdb-ready #7fd1a8; --cdb-track rgb(239 232 220 / 0.1). Treat these as the root colour tokens, one value per role, and name them to suit your code. Select it with the theme option set to "night". Keep every dimension, spacing value, state and motion from the brief unchanged, and keep text at 4.5:1 contrast or better on these surfaces. This selection takes precedence over references to other themes or options in the general brief. Implement this selected appearance; do not add a variant picker or alternative appearances unless requested. Implementation requirements: Use React and TypeScript. Keep the component self-contained, with uniquely scoped CSS and no animation libraries. Include required imports, styles and font setup in the result. Interaction: Wait for the border to drain, then press to resend; it starts the wait again. Motion: Arc drains continuously over the cooldown; a 900ms glow when it's ready. Accessibility: Uses aria-disabled instead of disabled, so the button stays focusable and its label says how long is left; readiness and resends are announced politely. Reduced motion keeps the timer but drops the glow. Responsive behavior: The outline is rebuilt from the measured size. Preserve keyboard access, visible focus and reduced-motion behavior. Keep fictional demo data and simulated service calls in a separate usage example; expose callbacks for real actions and recover from rejected requests. Keep usage-example links inside the demo: use local buttons or prevent navigation. Demonstration links must not navigate to Vitrine routes or open other pages; preserve real URL support in the reusable component itself. Verify the result at narrow and wide viewport sizes, with keyboard input and reduced motion enabled.

Notes

Interaction
Wait for the border to drain, then press to resend; it starts the wait again.
Motion
Arc drains continuously over the cooldown; a 900ms glow when it's ready.
Accessibility
Uses aria-disabled instead of disabled, so the button stays focusable and its label says how long is left; readiness and resends are announced politely. Reduced motion keeps the timer but drops the glow.
Responsive
The outline is rebuilt from the measured size.