OTP Input

A one-time password input with individual character fields. Supports auto-focus, paste handling, and a completion callback.

Installation

npm install @bloomkit/react

Usage

import { OTPInput } from "@bloomkit/react";
 
<OTPInput length={6} onComplete={(code) => console.log(code)} />

Controlled

const [value, setValue] = useState("");
 
<OTPInput length={6} value={value} onChange={setValue} />

Four digits

<OTPInput length={4} onComplete={(pin) => verify(pin)} />

Auto-focus

<OTPInput length={6} autoFocus />

Disabled

<OTPInput length={6} disabled />

Props

PropTypeDefaultDescription
lengthnumber6Number of input fields
valuestringControlled value
onChange(value: string) => voidCalled on each character change
onComplete(value: string) => voidCalled when all fields are filled
disabledbooleanfalsePrevents interaction
autoFocusbooleanfalseFocuses the first field on mount
classNamestring""Additional Tailwind classes