OTP Input

A verification code field with one box per character, on Base UI's OTP Field.

@cupertinoui/input-otpBase UI OTP Field Registry JSON

Installation

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

The first install also adds the macOS theme. See Installation to set up the registry.

Usage

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

<InputOTP length={6}>
  <InputOTPGroup>
    <InputOTPSlot index={0} />
    {/* … */}
  </InputOTPGroup>
</InputOTP>
Built on Base UI's OTP Field rather than the input-otp package: typing moves to the next box, Backspace goes back and pasting fills them all.

API Reference

Every part forwards the props of the underlying Base UI OTP Field part. The props below are the ones CupertinoUI adds or changes.

InputOTP

PropTypeDescription
lengthnumberHow many characters.
value / defaultValuestringThe code.
onValueChange / onValueComplete(value: string) => voidCalled as it changes, and once every box is filled.
classNamestringExtra classes, merged with the component's own.

InputOTPSlot

PropTypeDescription
indexnumberIts position, for the accessible label.
classNamestringExtra classes, merged with the component's own.