v1.3.0 28

OTP / PIN Input

Verification code input with individual character boxes. Use for OTP codes, PINs, and other segmented numeric inputs. Supports masked mode for secure entry.

Interactive Requires: veritheme.js JS init: automatic

Default

Standard 6-digit verification code input.

html

Enter the 6-digit code sent to your email

<div class="vt-flex vt-items-center vt-gap-2" data-vt-otp="">
  <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell" aria-label="Digit 1 of 6" aria-describedby="otp-input-1-1">
  <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell" aria-label="Digit 2 of 6" aria-describedby="otp-input-1-1">
  <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell" aria-label="Digit 3 of 6" aria-describedby="otp-input-1-1">
  <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell" aria-label="Digit 4 of 6" aria-describedby="otp-input-1-1">
  <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell" aria-label="Digit 5 of 6" aria-describedby="otp-input-1-1">
  <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell" aria-label="Digit 6 of 6" aria-describedby="otp-input-1-1">
</div>
<p class="vt-body-sm vt-text-foreground-muted" id="otp-input-1-1">Enter the 6-digit code sent to your email</p>

4-Digit

Shorter 4-digit verification code input.

html

Enter your 4-digit code

<div class="vt-flex vt-items-center vt-gap-2" data-vt-otp="">
  <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell" aria-label="Digit 1 of 4" aria-describedby="otp-input-2-1">
  <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell" aria-label="Digit 2 of 4" aria-describedby="otp-input-2-1">
  <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell" aria-label="Digit 3 of 4" aria-describedby="otp-input-2-1">
  <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell" aria-label="Digit 4 of 4" aria-describedby="otp-input-2-1">
</div>
<p class="vt-body-sm vt-text-foreground-muted" id="otp-input-2-1">Enter your 4-digit code</p>

With Separator

6-digit code split into two groups of three with a dash separator.

html
–
<div class="vt-flex vt-items-center vt-gap-2" data-vt-otp="">
  <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell" aria-label="Digit 1 of 6">
  <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell" aria-label="Digit 2 of 6">
  <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell" aria-label="Digit 3 of 6">
  <span class="vt-text-xl vt-text-foreground-muted vt-font-mono vt-px-1">–</span>
  <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell" aria-label="Digit 4 of 6">
  <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell" aria-label="Digit 5 of 6">
  <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell" aria-label="Digit 6 of 6">
</div>

Masked

Input with masked values for secure PIN entry.

html
●
●
●
●

PIN is hidden for security

<div class="vt-flex vt-items-center vt-gap-3" data-vt-otp="">
  <div class="vt-otp-cell vt-otp-cell-lg">●</div>
  <div class="vt-otp-cell vt-otp-cell-lg">●</div>
  <div class="vt-otp-cell vt-otp-cell-lg">●</div>
  <div class="vt-otp-cell vt-otp-cell-lg">●</div>
</div>
<p class="vt-body-sm vt-text-foreground-muted">PIN is hidden for security</p>

With Label

html

4-digit numeric code

<div class="vt-flex vt-flex-col vt-items-center vt-gap-3">
  <label class="vt-label vt-text-foreground-primary">Enter your PIN</label>
  <div class="vt-flex vt-items-center vt-gap-3" data-vt-otp="">
    <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell" aria-label="Digit 1 of 4" aria-describedby="otp-input-5-1">
    <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell" aria-label="Digit 2 of 4" aria-describedby="otp-input-5-1">
    <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell" aria-label="Digit 3 of 4" aria-describedby="otp-input-5-1">
    <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell" aria-label="Digit 4 of 4" aria-describedby="otp-input-5-1">
  </div>
  <p class="vt-body-sm vt-text-foreground-muted" id="otp-input-5-1">4-digit numeric code</p>
</div>

Sizes

vt-otp-cell-sm (32×40) and vt-otp-cell-lg (48×56) around the 40×48 default.

html

Small

Large

<div>
  <p class="vt-label-sm vt-text-foreground-muted vt-mb-2 vt-text-center" id="otp-input-6-1">Small</p>
  <div class="vt-flex vt-items-center vt-gap-2" data-vt-otp="">
    <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell vt-otp-cell-sm" aria-label="Digit 1 of 6" aria-describedby="otp-input-6-1">
    <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell vt-otp-cell-sm" aria-label="Digit 2 of 6" aria-describedby="otp-input-6-1">
    <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell vt-otp-cell-sm" aria-label="Digit 3 of 6" aria-describedby="otp-input-6-1">
    <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell vt-otp-cell-sm" aria-label="Digit 4 of 6" aria-describedby="otp-input-6-1">
    <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell vt-otp-cell-sm" aria-label="Digit 5 of 6" aria-describedby="otp-input-6-1">
    <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell vt-otp-cell-sm" aria-label="Digit 6 of 6" aria-describedby="otp-input-6-1">
  </div>
</div>

<div>
  <p class="vt-label-sm vt-text-foreground-muted vt-mb-2 vt-text-center" id="otp-input-6-2">Large</p>
  <div class="vt-flex vt-items-center vt-gap-3" data-vt-otp="">
    <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell vt-otp-cell-lg" aria-label="Digit 1 of 6" aria-describedby="otp-input-6-2">
    <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell vt-otp-cell-lg" aria-label="Digit 2 of 6" aria-describedby="otp-input-6-2">
    <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell vt-otp-cell-lg" aria-label="Digit 3 of 6" aria-describedby="otp-input-6-2">
    <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell vt-otp-cell-lg" aria-label="Digit 4 of 6" aria-describedby="otp-input-6-2">
    <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell vt-otp-cell-lg" aria-label="Digit 5 of 6" aria-describedby="otp-input-6-2">
    <input type="text" inputmode="numeric" maxlength="1" class="vt-otp-cell vt-otp-cell-lg" aria-label="Digit 6 of 6" aria-describedby="otp-input-6-2">
  </div>
</div>

Filled State

Input with values already entered.

html

Code entered successfully

<div class="vt-flex vt-items-center vt-gap-2" data-vt-otp="">
  <input type="text" inputmode="numeric" maxlength="1" value="4" readonly="" class="vt-otp-cell" aria-label="Digit 1 of 6" aria-describedby="otp-input-7-1">
  <input type="text" inputmode="numeric" maxlength="1" value="2" readonly="" class="vt-otp-cell" aria-label="Digit 2 of 6" aria-describedby="otp-input-7-1">
  <input type="text" inputmode="numeric" maxlength="1" value="8" readonly="" class="vt-otp-cell" aria-label="Digit 3 of 6" aria-describedby="otp-input-7-1">
  <input type="text" inputmode="numeric" maxlength="1" value="1" readonly="" class="vt-otp-cell" aria-label="Digit 4 of 6" aria-describedby="otp-input-7-1">
  <input type="text" inputmode="numeric" maxlength="1" value="5" readonly="" class="vt-otp-cell" aria-label="Digit 5 of 6" aria-describedby="otp-input-7-1">
  <input type="text" inputmode="numeric" maxlength="1" value="6" readonly="" class="vt-otp-cell" aria-label="Digit 6 of 6" aria-describedby="otp-input-7-1">
</div>
<p class="vt-body-sm vt-text-foreground-muted" id="otp-input-7-1">Code entered successfully</p>

Error State

vt-otp-cell-error on every cell, with aria-invalid="true" and a vt-field-error message announced by role="alert".

html
<div class="vt-flex vt-items-center vt-gap-2" data-vt-otp="">
  <input type="text" inputmode="numeric" maxlength="1" value="7" readonly="" aria-invalid="true" class="vt-otp-cell vt-otp-cell-error" aria-label="Digit 1 of 6" aria-describedby="otp-input-8-1">
  <input type="text" inputmode="numeric" maxlength="1" value="3" readonly="" aria-invalid="true" class="vt-otp-cell vt-otp-cell-error" aria-label="Digit 2 of 6" aria-describedby="otp-input-8-1">
  <input type="text" inputmode="numeric" maxlength="1" value="9" readonly="" aria-invalid="true" class="vt-otp-cell vt-otp-cell-error" aria-label="Digit 3 of 6" aria-describedby="otp-input-8-1">
  <input type="text" inputmode="numeric" maxlength="1" value="0" readonly="" aria-invalid="true" class="vt-otp-cell vt-otp-cell-error" aria-label="Digit 4 of 6" aria-describedby="otp-input-8-1">
  <input type="text" inputmode="numeric" maxlength="1" value="4" readonly="" aria-invalid="true" class="vt-otp-cell vt-otp-cell-error" aria-label="Digit 5 of 6" aria-describedby="otp-input-8-1">
  <input type="text" inputmode="numeric" maxlength="1" value="2" readonly="" aria-invalid="true" class="vt-otp-cell vt-otp-cell-error" aria-label="Digit 6 of 6" aria-describedby="otp-input-8-1">
</div>
<p class="vt-field-error" role="alert" id="otp-input-8-1">Invalid verification code. Please try again.</p>

Success State

vt-otp-cell-success once the code is accepted.

html
●
●
●
●

PIN verified

<div class="vt-flex vt-items-center vt-gap-3" data-vt-otp="">
  <div class="vt-otp-cell vt-otp-cell-lg vt-otp-cell-success">●</div>
  <div class="vt-otp-cell vt-otp-cell-lg vt-otp-cell-success">●</div>
  <div class="vt-otp-cell vt-otp-cell-lg vt-otp-cell-success">●</div>
  <div class="vt-otp-cell vt-otp-cell-lg vt-otp-cell-success">●</div>
</div>
<p class="vt-field-success">PIN verified</p>

Guidelines

Do Give each digit its own equal-sized box.
Don't Don't mix cell sizes — keep every digit box identical.

API Reference

Class Type Description
vt-otp-cell Base One character: 40×48px, monospace Body/LG, centered; the default size
vt-otp-cell-sm Size Small cell — 32×40px, Body/SM
vt-otp-cell-lg Size Large cell — 48×56px, Heading/SM
vt-otp-cell-error State Error border (and an error focus ring) — pair with aria-invalid="true"
vt-otp-cell-success State Success border (and a success focus ring)
inputmode="numeric" Attribute Mobile keyboard shows numeric keypad
maxlength="1" Attribute Restricts input to single character

Accessibility

Feature Details
Auto-advance Input automatically moves focus to next box when filled
Backspace Backspace moves focus to previous box when current is empty
Paste Support Pasting full code distributes digits across all inputs
ARIA Label Use aria-label on each input: "Digit 1 of 6", "Digit 2 of 6", etc.
Error Feedback Use aria-invalid and role="alert" for error messages