Skip to content

No.377 · Authentication

Code Cascade Verify

A one-time-code screen where a pasted code drops into its six cells one after another, a wrong code sends a damped wave along the row from the cell you were on, and a right one rolls the digits away into a single Verified pill.

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 an email-code verification card: a title, 'Enter the 6-digit code we sent to h•••@tryvitrine.dev', six drawn cells, a status line, a Resend button and a 'Use a different email' link. Use one real <input inputMode="numeric" autoComplete="one-time-code" maxLength={6}> laid transparently over the whole row (transparent text and caret), so typing, pasting and SMS/email autofill all work; the cells are aria-hidden drawings of its value. The cell at the cursor gets an accent ring and a blinking caret while focused. When several digits arrive at once, give each new digit an animation delay of 70ms × its position among the new ones, so a paste drops in left to right (each digit rises 70% with a slight overshoot, 360ms). At six digits, verify automatically: a soft pulse passes along the cells while checking. Wrong: tint the cells red and run a damped vertical wave (−9px, +5px, −2px) outward from the last-typed cell, each cell delayed 60ms per cell of distance with its amplitude shrinking — flip between two identical keyframes so it replays every time — then clear after 900ms and refocus. Say what to do in a role=alert line. Right: the digits roll up and away in order and a single green 'Verified' pill scales in over the row as its check draws. Resend counts down 30s as a line round the pill-shaped button: a conic-gradient ring (registered --p, 1 → 0) masked to 1.5px with mask-composite exclude. At zero, the ring's padding grows until it fills the pill and the label becomes 'Resend code'. Paper and Night. Require an async verify callback. Catch rejected verification requests, announce errors and allow retry. Offer resend only when an async onResend callback is supplied; restart the countdown only after it succeeds. Use a configurable changeEmailHref and omit it when absent. Simulated verification belongs only in demo.tsx. Selected variant — Night (night): Palette for this theme (Night): --ccv-accent #b9cce4; --ccv-bg #141217; --ccv-cell #1b191f; --ccv-err #f08a7a; --ccv-focus #b9cce4; --ccv-ink #efe8dc; --ccv-line rgb(239 232 220 / 0.16); --ccv-muted #9c96a1; --ccv-ok #7fd1a8; --ccv-rim 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: Type or paste the code (the demo accepts 246810). Wait out the countdown to resend. Motion: Digits drop in 360ms, 70ms apart; wrong-code wave 620ms, 60ms per cell; success roll-out 420ms staggered, then the pill and check. Accessibility: A single labelled input with one-time-code autocomplete and aria-describedby on the status line; errors are role=alert and set aria-invalid. The input becomes read-only while checking and after success. Resend uses aria-disabled during the countdown so it stays focusable and readable. Reduced motion collapses every animation to an instant change. Responsive behavior: Up to 25rem; cells tighten under 400px. Touch: The numeric keypad opens; iOS and Android offer the code from the message. 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
Type or paste the code (the demo accepts 246810). Wait out the countdown to resend.
Motion
Digits drop in 360ms, 70ms apart; wrong-code wave 620ms, 60ms per cell; success roll-out 420ms staggered, then the pill and check.
Accessibility
A single labelled input with one-time-code autocomplete and aria-describedby on the status line; errors are role=alert and set aria-invalid. The input becomes read-only while checking and after success. Resend uses aria-disabled during the countdown so it stays focusable and readable. Reduced motion collapses every animation to an instant change.
Responsive
Up to 25rem; cells tighten under 400px.
On touch
The numeric keypad opens; iOS and Android offer the code from the message.