Skip to content

No.446 · Forms

Ribbon OTP

A one-time-code input as a single ribbon of cells: digits drop in, a light sweeps the ribbon on success, and it shakes on failure.

The prompt

Copy this text

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

The design brief behind this component — reuse it to regenerate, remix, or explain it.

Design a verification-code input that reads as one object rather than six boxes. A single 14px-rounded ribbon (near-black plum, hairline border, faint top highlight) is divided into equal cells by hairline dividers. Each cell is a real numeric <input> in a mono face at 1.5rem. Focus shows a frost underline and a faint frost wash on the active cell. Typing a digit fills the cell with a small drop-and-settle (240ms, overshoot) and advances focus; Backspace clears then moves back; arrow keys move; pasting a code fills all cells. When every cell is filled the code is submitted: on success a band of frost light sweeps across the whole ribbon (800ms) and the border turns frost; on failure the ribbon shakes, digits turn rose, and after 700ms it clears and refocuses the first cell. Use autocomplete="one-time-code" on the first cell, an accessible label per cell, and a polite live region for the result. 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 digits; Backspace/←/→ navigate; completion verifies automatically. Motion: Digit drop 240ms; success sweep 800ms; failure shake 380ms. Accessibility: A labelled group; each cell has 'Digit n of N' as its name; autocomplete one-time-code; result announced via aria-live. Reduced motion removes the drop, shake and sweep. Responsive behavior: Cells shrink below 26rem so six digits always fit. 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 digits; Backspace/←/→ navigate; completion verifies automatically.
Motion
Digit drop 240ms; success sweep 800ms; failure shake 380ms.
Accessibility
A labelled group; each cell has 'Digit n of N' as its name; autocomplete one-time-code; result announced via aria-live. Reduced motion removes the drop, shake and sweep.
Responsive
Cells shrink below 26rem so six digits always fit.