Back to Components

Form

PinInput

Fixed-length OTP / verification code field. Auto-advance on input, backspace clears + moves back, paste fills all slots.

Examples

6-digit OTP

Value: (empty)
<PinInput
  bind:value={otp}
  length={6}
  onComplete={(code) => alert(code)}
/>

Masked, alphanumeric

<PinInput length={4} pattern="alphanumeric" mask />

Props

PropTypeDefaultDescription
valuestring''Bindable string of entered characters.
lengthnumber6Number of slots to render.
pattern'numeric' | 'alphanumeric''numeric'Allowed character class.
maskbooleanfalseUse type=password to mask each slot.
autoFocusbooleanfalseFocus the first slot on mount.
onComplete(code: string) => voidFires when all slots are filled.

Install

CLI

npx @a3tai/mittsu add pin-input