Input OTP

An accessible and flexible component for one-time password entry.

input-otp

Installation


1

Install the following dependencies:

npx shadcn@latest add https://sbthemes.com/r/input-otp.json

Examples


Separator

Use the <InputOTPSeparator /> component to visually separate groups of OTP inputs.

Validation

Displays an OTP input with error handling and visual feedback for invalid codes.

Controlled

Use the value and onChange props to manage the OTP input as a controlled component.

Pattern

Set a custom validation pattern for the OTP input with the pattern prop.

Form


API Reference

InputOTP

PropTypeDefault
valuestring-
defaultValuestring-
maxLengthnumber6
patternstring-
disabledbooleanfalse
containerClassNamestring-
classNamestring-
onChange(value: string) => void-
onComplete(value: string) => void-

InputOTPSlot

PropTypeDefault
indexnumber-