HextaUI

Input OTP: Masked

mask hides each character, for PINs. Turn autofill off with autoComplete="off" when the value is not a one-time code.

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

export function InputOTPMasked() {
  return (
    <InputOTP
      length={4}
      mask
      animated
      variant="separate"
      autoComplete="off"
      aria-label="PIN"
    >
      <InputOTPGroup>
        <InputOTPSlot />
        <InputOTPSlot />
        <InputOTPSlot />
        <InputOTPSlot />
      </InputOTPGroup>
    </InputOTP>
  )
}

This adds the example as components/examples/input-otp/masked.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-masked.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–
variant
"joined" | "separate""joined"
animatedAnimate characters in and out, cascade multi-character input and animate the status.
booleanfalse
autoComplete
string"one-time-code"
mask
booleanfalse

Every prop is in the Input OTP API reference.

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