Skip to content
GitHub (opens in a new tab)

InputOTP

One-time code or PIN as separate slots.

stableMoleculecontracts/inputotp.json

Preview

InputOTP

One-time code or PIN as separate slots. One native input so paste and autocomplete work. Not a row of Inputs.

Master

Field-wrapped 6-digit code at md with a 3-3 separator. Variants shows other lengths, disabled and error.

Type or paste a 6-digit code

Usage

Wrap with Field. Default length is 6 with groups [3, 3]. Paste fills the concatenated value. Unlabeled needs ariaLabel.

Do's

  • email/SMS verification, PIN, 2FA code

Don'ts

  • normal text — Input
  • multi-line — Textarea
  • choosing options — Select/RadioGroup
<Field label="Verification code" htmlFor="otp">
  <InputOTP
    id="otp"
    size="md"
  />
</Field>

One-time code / PIN as separate slots. Paste and autocomplete work. Not a row of Inputs.

When to use

  • email/SMS verification, PIN, 2FA code

When not to use

  • normal text — Input
  • multi-line — Textarea
  • choosing options — Select/RadioGroup

What an agent reads

import { InputOTP } from "agentic-ds-kit";
must
  • Single native input so paste, autocomplete, and form submit work
  • id associates with Field htmlFor
  • Unlabeled needs Field or ariaLabel (default One-time code)
  • aria-invalid when error
  • describedBy lands on the input as aria-describedby
  • Disabled is exposed on the input
defaults
  • length 6
  • size md
  • disabled false
  • error false
  • pattern digits
  • autoComplete one-time-code
stops if
  • Do not invent InputOTPGroup, InputOTPSlot, or InputOTPSeparator
  • Do not wrap kit Input N times
  • Do not add the input-otp package
  • Do not use raw hex
  • Do not use Lucide except via LucideByName from @/ui/Button/lucideName
  • Unlabeled needs Field or ariaLabel

From contracts/inputotp.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
describedBystringNo—Id(s) for aria-describedby on the input. Field passes its hint or error id.
idstringYes——
lengthnumberNo6—
groupsnumber[]No—Slot counts per group; must sum to length. Default [3, 3] when length is 6, else [length]. Separator sits between groups only.
sizesm | md | lgNomd—
disabledbooleanNofalse—
errorbooleanNofalse—
valuestringNo—controlled
defaultValuestringNo—uncontrolled
onChangefunctionNo—(value: string) => void
onCompletefunctionNo—fires when value.length === length
patterndigits | alphanumericNodigits—
namestringNo——
autoCompletestringNoone-time-code—
ariaLabelstringNo—required when not wrapped in Field
  • Component
    →

    Input

    Single-line text entry for forms and filters.

  • Component
    →

    Textarea

    Multi-line text entry for notes and descriptions.

  • Component
    →

    Select

    Choose one or several options from a list.

  • Component
    →

    RadioGroup

    Choose exactly one option from a small visible set.