Skip to main content

Input OTP

A one-time passcode input with a spring-gliding active slot ring, blur-pop digit reveal, blinking caret, and invalid shake.

3/6digits

Customize

SizeMedium (md)
Digit blur (px)4
Spring speed1

Installation

npx shadcn@latest add @kinetic/input-otp

Usage

import {
  InputOTP,
  InputOTPGroup,
  InputOTPSlot,
} from "@/components/kinetic/ui/input-otp";

export function VerifyCode() {
  return (
    <InputOTP maxLength={6}>
      <InputOTPGroup>
        <InputOTPSlot index={0} />
        <InputOTPSlot index={1} />
        <InputOTPSlot index={2} />
        <InputOTPSlot index={3} />
        <InputOTPSlot index={4} />
        <InputOTPSlot index={5} />
      </InputOTPGroup>
    </InputOTP>
  );
}

Separator

Use InputOTPSeparator between groups to split a code visually.

<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>

Controlled value and completion

Use value with onValueChange, or defaultValue for an uncontrolled field. onComplete fires when all slots are filled. maxLength defaults to 6. Pasting a code fills the slots, and the field sets autoComplete="one-time-code".

const [code, setCode] = React.useState("");

<InputOTP
  maxLength={6}
  value={code}
  onValueChange={setCode}
  onComplete={(value) => verify(value)}
>
  {/* slots */}
</InputOTP>

Pattern

pattern accepts numeric (default) or alphanumeric.

<InputOTP maxLength={4} pattern="alphanumeric">
  {/* slots */}
</InputOTP>

Sizes

Use size with sm, md, or lg.

<InputOTP maxLength={6} size="lg">
  {/* slots */}
</InputOTP>

States

invalid plays a shake when the field becomes invalid and marks it invalid. disabled and readOnly prevent editing.

<InputOTP maxLength={6} invalid>
  {/* slots */}
</InputOTP>

Motion preferences

The active ring glide, digit reveal, caret blink, and shake respect the Kinetic reduced-motion setting and the browser preference. Durations use the current tempo and the speed prop.

API Reference

InputOTP

Zero-dependency one-time passcode input with spring-gliding active ring, per-slot blur-pop reveal, completion wave, and invalid shake.

PropTypeDefaultDescription
maxLengthnumber6Total number of passcode slots.
value / defaultValue / onValueChange / onCompletestring / (value: string) => void-Controlled or initial code string, live change callback, and completion callback.
pattern"numeric" | "alphanumeric""numeric"Filters allowed characters to digits only or letters and digits.
size / blurPx / speed / invalid / disabled"sm" | "md" | "lg" / number / boolean"md" / 4 / 1 / false / falseSlot size scale, digit blur radius, spring speed, invalid shake state, and disabled state.

Notes

Ensure maxLength matches the exact number of InputOTPSlot elements and connect id with FieldLabel htmlFor for screen-reader focus announcements.