OTP Input

An accessible one-time-passcode input made of auto-advancing digit boxes, each with a spring-driven pop animation on entry, built with Framer Motion and Tailwind CSS.

Installation

Add the component directly to your repository using shadcn CLI:

npx shadcn@latest add Surajmaurya1/easyui/otp-input

API Reference

PropTypeDefaultDescription
lengthnumber6Number of digit boxes to render
valuestringundefinedControlled value; omit to let the component manage its own state
onChange(value: string) => voidundefinedCalled with the joined code whenever any digit changes
onComplete(value: string) => voidundefinedCalled once with the full code when every box is filled
autoFocusbooleanfalseFocuses the first box on mount
disabledbooleanfalseDisables all digit boxes
classNamestringundefinedClasses applied to the wrapping group element
boxClassNamestringundefinedClasses applied to each individual digit box