Input Otp

A flexible Accessible one-time password component

Installation

npx shadcn@latest add https://scrollx-ui.vercel.app/registry/input-otp.json 

Usage

import {
  InputOTP,
  InputOTPGroup,
  InputOTPSeparator,
  InputOTPSlot,
} from "@/components/ui/input-otp"
<InputOTP maxLength={6} mask={true} maskDelay={1200}>
  <InputOTPGroup>
    <InputOTPSlot index={0} />
    <InputOTPSlot index={1} />
    <InputOTPSlot index={2} />
  </InputOTPGroup>
  <InputOTPSeparator separatorSymbol="+"  />
  <InputOTPGroup>
    <InputOTPSlot index={3} />
    <InputOTPSlot index={4} />
    <InputOTPSlot index={5} />
  </InputOTPGroup>
</InputOTP>

API Reference

Input Otp

The InputOTP is a root component that creates an animated OTP input field with masking support and paste functionality.

Props

PropertyTypeDefaultDescription
maxLengthnumberrequired
Total number of OTP digits. Used in: InputOTP.
onComplete(otp: string) => void
Callback fired when OTP is fully entered. Used in: InputOTP.
maskbooleanfalse
Whether to mask each digit. Used in: InputOTP.
maskSymbolstring
Symbol to show when masking. Used in: InputOTP.
maskDelaynumber1000
Delay (ms) before masking input. Used in: InputOTP.
indexnumberrequired
Slot index position. Used in: InputOTPSlot.
separatorSymbolstring'-'
Symbol displayed between OTP slots. Used in: InputOTPSeparator.
classNamestring
Optional styling class. Used in: InputOTP, InputOTPGroup, InputOTPSlot, InputOTPSeparator.
containerClassNamestring
Class name for outer container. Used in: InputOTP.
inputClassNamestring
Class name for each OTP input. Used in: InputOTP.
childrenReactNodeoptional
Nested content. Used in: InputOTP, InputOTPGroup.

Built withby Ahdeetai.