Skip to content

Input OTP

InputOTP handles multi-digit verification codes and OTP pin inputs.

Usage

OTPExample.tsx
import { useState } from 'react';
import { InputOTP, InputOTPGroup, InputOTPSlot } from '@masumdev/rn-ui';
export function OTPExample() {
const [value, setValue] = useState('');
return (
<InputOTP maxLength={4} value={value} onChange={setValue}>
<InputOTPGroup>
<InputOTPSlot index={0} />
<InputOTPSlot index={1} />
<InputOTPSlot index={2} />
<InputOTPSlot index={3} />
</InputOTPGroup>
</InputOTP>
);
}

Props API

PropTypeDefaultDescription
valuestringCurrent OTP digit value.
onChange(value: string) => voidCallback when digits are entered.
maxLengthnumber4Total number of OTP digits.