HextaUI

Input OTP: Sizes

sm, default and lg match the input and button heights. On touch screens every size grows to at least 44px with a 16px font.

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

export function InputOTPSizes() {
  return (
    <div className="flex max-w-full min-w-0 flex-col items-start gap-4">
      <InputOTP length={4} size="sm" aria-label="Small code">
        <InputOTPGroup>
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSlot />
        </InputOTPGroup>
      </InputOTP>
      <InputOTP length={4} aria-label="Default code">
        <InputOTPGroup>
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSlot />
        </InputOTPGroup>
      </InputOTP>
      <InputOTP length={4} size="lg" aria-label="Large code">
        <InputOTPGroup>
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSlot />
          <InputOTPSlot />
        </InputOTPGroup>
      </InputOTP>
    </div>
  )
}

This adds the example as components/examples/input-otp/sizes.tsx, together with the Input OTP component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/input-otp-sizes.json

To add only the component, follow the Input OTP installation.

Props in this example

The Input OTP props this example sets, from the API reference.

PropTypeDefault
lengthRequired. The number of slots; render the same number of InputOTPSlot parts.
number–
size
"sm" | "default" | "lg""default"

Every prop is in the Input OTP API reference.

See them all, with keyboard support and accessibility notes, on the Input OTP page.