← All Components

InputOTP

One-time password input with auto-focus and keyboard navigation. Built on input-otp.

Default

A standard 6-digit OTP input split into two groups of three.

Four Digits

A compact 4-digit OTP in a single group.

Alphanumeric

Accepts both letters and digits using REGEXP_ONLY_DIGITS_AND_CHARS.

Disabled

Props

PropTypeDescription
maxLengthnumberTotal number of input slots
valuestringControlled value
onChange(value: string) => voidCalled when value changes
disabledbooleanDisables the entire input
patternstring | RegExpRegex pattern to validate each character (e.g. REGEXP_ONLY_DIGITS)
containerClassNamestringAdditional classes on the outer container

Usage

import { InputOTP } from "@/components/ui"; <InputOTP maxLength={6}> <InputOTP.Group> <InputOTP.Slot index={0} /> <InputOTP.Slot index={1} /> <InputOTP.Slot index={2} /> </InputOTP.Group> <InputOTP.Separator /> <InputOTP.Group> <InputOTP.Slot index={3} /> <InputOTP.Slot index={4} /> <InputOTP.Slot index={5} /> </InputOTP.Group> </InputOTP>