Prodular UI

Input OTP

Enter a one-time code digit by digit, with paste and autofill support.

npx prodular-ui add input-otp

Six digits

4
8
2
1

Sent to the phone ending in 0417.

Invalid

Mark each slot with aria-invalid and say how many attempts are left.

1
2
0
9

Anatomy

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

Guidance

Use it when

  • Verification and recovery codes of four to eight characters.

Avoid

  • Passwords or anything longer than eight characters. Use Input.

Rules for AI agents

Published in llms-full.txt, the registry and the MCP server, so coding agents follow them when they build with this component.

  • Set maxLength to the code length and render one InputOTPSlot per index.
  • Use pattern={REGEXP_ONLY_DIGITS} from input-otp for numeric codes.
  • Give InputOTP an id and pass it to FieldLabel htmlFor.
  • Say where the code was sent in FieldDescription.

API

InputOTP

PropTypeDefaultDescription
maxLengthnumberNumber of characters.
patternstringAllowed characters as a regular expression string.

InputOTPSlot

PropTypeDefaultDescription
indexnumberWhich character this slot shows.

Installation

The Prodular UI CLI adds the source to components/ui with everything it depends on. In a project that already uses shadcn/ui, the shadcn CLI installs it from the Prodular registry too. See Installation for the first setup.

npx prodular-ui add input-otp# or, with the registry in components.jsonnpx shadcn@latest add @prodular/input-otp

Used in these screens