Skip to main content

Installation

Or use the CLI:

About

Input OTP is built on top of input-otp by @guilherme_rodz.

Usage

Component API

InputOTP

The root OTP input component. Props:
  • maxLength - Maximum number of characters (required)
  • value - Controlled value
  • onChange - Callback when value changes
  • pattern - Regex pattern for validation
  • disabled - Disable the input
  • containerClassName - Additional classes for container

InputOTPGroup

Groups OTP slots together.

InputOTPSlot

An individual OTP character slot. Props:
  • index - Slot index (required)
  • aria-invalid - Mark as invalid

InputOTPSeparator

Visual separator between groups.

Examples

Basic

A simple 6-digit OTP input:

Pattern

Use the pattern prop to define validation:

Separator

Add separators between groups:

Controlled

Control the input value:

Disabled

Disable the OTP input:

Invalid State

Show an error state:

Four Digits

A 4-digit PIN input:

Form

Use in a form with React Hook Form:

Accessibility

  • Built on input-otp for full accessibility
  • Keyboard navigation support
  • Copy/paste functionality
  • Screen reader compatible
  • Focus management
  • Auto-advance on input

API Reference

See the input-otp documentation for complete API details.