Search

Search documentation

Input OTP

Accessible one-time password component with copy paste functionality.

Installation

pnpm dlx shadcn@latest add @evolphin/input-otp

Usage

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

Type Definitions

import {  } from "input-otp";

type  = .<typeof >;

Examples

Default

Pattern (Alphanumeric)

Separator

API Reference

InputOTP

This component is a wrapper around input-otp. See the input-otp documentation for all available props.

PropTypeDefaultDescription
maxLengthnumber-The number of characters in the OTP.
patternstring-The regex pattern for valid characters.
classNamestring-Additional CSS classes

InputOTPGroup

PropTypeDefaultDescription
classNamestring-Additional CSS classes

InputOTPSlot

PropTypeDefaultDescription
indexnumber-The index of the slot in the OTP.
classNamestring-Additional CSS classes

InputOTPSeparator

PropTypeDefaultDescription
classNamestring-Additional CSS classes

On this page