Swish UI
All componentsFeedback and forms Pro

One time code input

Six digit boxes that auto advance, step back on backspace, fill all at once on paste and confirm when complete.

The React code for this component comes with Pro.

Unlock with Pro

Use it for

  • Verifying a phone or email with a short code
  • Payment or booking confirmation steps

Avoid

  • Codes longer than eight characters
  • Letting the boxes hide which digit has focus

How it works

Digits live in one array in state. Typing writes the digit and focuses the next box; backspace in an empty box clears and focuses the previous one; paste or one time code autofill spreads every digit from the current box onward. Each box gets data-filled, and a CSS keyframe on that attribute gives the small pop. When all six are filled the boxes turn accent with a staggered wave.

Accessibility

The boxes sit in a fieldset with a legend, each has a label like Digit 3 of 6, numeric input mode and one-time-code autocomplete on the first. Arrow keys move between boxes. The result is announced through a polite live region. Reduced motion drops the pop and wave.

Get the source with Pro

The demo above is free to play with. Pro unlocks the source of this and every other Pro component, with copy-ready code and a zip download.

Already bought? Sign in

Found on