Command Palette

Search for a command to run...

Docs
OTP Input

OTP Input

A one-time password input field with auto-focus and paste support

Loading...

Installation

Props

PropTypeDefaultDescription
lengthnumber6Number of input fields
onChange(value: string) => void-Callback when value changes
placeholderstring""Placeholder character for empty fields
autoFocusbooleantrueWhether to focus the first field on mount

Examples

Custom Length and Placeholder

<OTPInput
  length={4}
  placeholder="•"
  onChange={(val) => console.log("OTP:", val)}
/>

With Change Handler

const [otp, setOtp] = useState("");
 
<OTPInput
  length={6}
  onChange={(val) => setOtp(val)}
  placeholder="•"
/>
 
<p>Current OTP: {otp}</p>