Components

OTP input

A one-time-code field: a drop of light stretches to the next cell as you type, characters fall into place and a full code sends an iridescent wave across.

Paste it into ChatGPT, Claude, Cursor or v0.
length6
type

Usage

React
import { OTPInput } from '@vizzele/react';

const [code, setCode] = useState('');
const [wrong, setWrong] = useState(false);

<OTPInput
  value={code}
  onValueChange={(v) => {
    setCode(v);
    setWrong(false);
  }}
  onComplete={async (v) => setWrong(!(await verify(v)))}
  invalid={wrong}
  groupSize={3}
  autoFocus
/>

Props

PropTypeDefaultDescription
lengthnumber6Number of cells.
value / defaultValue / onValueChangestring—Controlled or uncontrolled.
onComplete(code: string) => void—Fires once, when the last cell is filled.
type'numeric' | 'alphanumeric''numeric'Allowed characters; letters are uppercased.
groupSizenumber—Draw a gap every n cells.
maskboolean—Show dots instead of characters.
invalidboolean—Shake once and turn red.
labelstring'One-time code'Accessible name.
namestring—Submitted with forms.

Accessibility

  • One real input underneath the cells — paste, SMS autofill (autocomplete="one-time-code"), the numeric keypad and screen readers all work as with any field.
  • Invalid sets aria-invalid. Reduced motion: characters appear without falling and the wave and shake are off.