VisorVisor
ComponentsForm

OTP Input

A multi-digit OTP/verification code input with auto-advance and paste support.

Default (6 Digits)

4-Digit PIN

Disabled

Installation

npx visor add otp-input

This copies two files into your project:

  • components/ui/otp-input/otp-input.tsx — the component
  • components/ui/otp-input/otp-input.module.css — the styles

Usage

import { OTPInput } from '@/components/ui/otp-input/otp-input';

<OTPInput length={6} onChange={(code) => console.log(code)} />

API Reference

OTPInputProps

PropTypeDefaultDescription
lengthnumber6Number of digit cells.
valuestringControlled value (digits only).
onChange(value: string) => voidCallback when the code changes.
disabledbooleanfalseDisables all digit cells.
autoFocusbooleanfalseAuto-focus the first cell on mount.

Accessibility

  • Each digit cell renders as type="text" with inputmode="numeric" and maxlength="1"
  • Cells are grouped inside a <div role="group"> with an accessible label (e.g., aria-label="One-time password")
  • Focus auto-advances to the next cell on digit entry and moves back on Backspace
  • Paste support fills all cells from clipboard and focuses the last filled cell
  • Provide a descriptive aria-label prop on the group for screen reader context (e.g., "Enter your 6-digit verification code")