Bencho Originals

Features

  • One real input sits over the cells, so typing, paste and SMS autofill (autocomplete="one-time-code") all work.
  • Each digit rises in from below, un-blurring as it settles, while its cell swells slightly.
  • A thin caret blinks in the next empty cell.
  • Accept: the cells slide together under a goo filter and turn into a ✓ Verified capsule, then reset.
  • Reject: the digits turn red, the row shakes with a decaying wobble, and the digits drop out right to left.
  • verify can be a function (sync or async) that checks the code for real.

API reference

<OneTimeCode /> from components/bencho/one-time-code.tsx

PropTypeDefaultDescription
length4 | 64Number of digits.
verify"accept" | "reject" | (code) => boolean | Promise<boolean>"accept"What happens when the last digit is entered.
cornernumber12Cell corner radius in px.
outlinedbooleanfalseAdds a hairline ring around the card, for busy backgrounds.
onComplete(code: string, ok: boolean) => void—Called once the code has been checked.

Keyboard interactions

TabFocuses the code field.
0–9Types a digit into the next cell.
BackspaceRemoves the last digit.
EscapeClears the field and leaves it.

Accessibility

  • It's a single <input inputmode="numeric"> labelled like “4-digit verification code”, not a row of separate inputs.
  • The cells are aria-hidden; the result (“Code verified” or “Code rejected”) is announced through a polite live region.
  • The Verified capsule is a role="status".

Sound & haptics

Silent by design: no audio and no vibration. All of the feedback is visual, so it works anywhere, muted or not.

Files

Written from scratch for sher.md and inspired by bencho.dev. It contains none of bencho's code or assets.