Skip to content

Input OTP

The InputOTP component provides a user-friendly interface for entering one-time passwords with individual slots and automatic focus management.

import { InputOTP } from "@rhinolabs/ui";
export default function InputOTPDemo() {
const [otp, setOtp] = useState("");
return (
<InputOTP maxLength={6} value={otp} onChange={setOtp}>
<InputOTP.Group>
<InputOTP.Slot index={0} />
<InputOTP.Slot index={1} />
<InputOTP.Slot index={2} />
<InputOTP.Slot index={3} />
<InputOTP.Slot index={4} />
<InputOTP.Slot index={5} />
</InputOTP.Group>
</InputOTP>
);
}
<InputOTP maxLength={6} value={otp} onChange={setOtp}>
<InputOTP.Group>
{Array.from({ length: 6 }).map((_, i) => (
<InputOTP.Slot key={i} index={i} />
))}
</InputOTP.Group>
</InputOTP>
<InputOTP maxLength={6} value={otp} onChange={setOtp}>
<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>
PropTypeDefaultDescription
maxLengthnumber-Maximum OTP length.
valuestring-Current OTP value.
onChange(value: string) => void-Change handler.
containerClassNamestring-Container CSS class.

The InputOTP component supports keyboard navigation and provides proper ARIA labels for screen readers.