Ballmac UI home

Input OTP

A one-time-code field with grouped slots, separator, caret, paste and autofill support, invalid state and reduced-motion-safe animation, on a single real input.

Enter the 6 digits we sent to j••••@acme.example. Try 123456.

Installation

$ pnpm dlx shadcn@latest add @ballmac/input-otp

Usage

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

The full example is in the Code tab above.

Examples

PIN, invalid, disabled

PIN

4
2

Invalid

0
0
0
0

Disabled

1
2
3
4

API reference

<InputOTP>

PropTypeDefault
containerClassName

Classes for the wrapper around the slots (use `className` for the hidden input).

string—

<InputOTPSlot>

PropTypeDefault
index*

Position of this slot in the code, starting at 0.

number—
invalid

Mark the slot invalid (destructive border) without changing the field.

boolean—

Also accepts the standard attributes of its root element.

Accessibility

KeyAction
Type / pasteFills slots; autofill works with one-time-code
Backspace / arrowsEdit like a normal text field
Screen readersOne text input is announced, not six boxes

Use with AI

<InputOTP maxLength={6}> with InputOTPGroup, InputOTPSlot index and InputOTPSeparator. onComplete fires when every slot is filled. With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI Input OTP (@ballmac/input-otp) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • Two-step sign-in and email verification
  • PIN entry

Not for

  • Free-form text codes; use input
  • Long passwords; use password-input

Registry JSON: https://ui.ballmac.com/r/input-otp.json

Credits

Based on shadcn/ui Input OTP, adapted by Ballmac. Free to use in personal and commercial projects.

Registry
shadcn/utils