structyl

One-Time Password Field

stable

A segmented input for OTP / PIN codes.

Basic usage

Examples

6-digit OTP

A six-cell OTP input with completion callback.

Four and six digit codes

Use segmented inputs for OTP, PIN and confirmation code flows.

Features

  • Paste support.
  • Numeric or alphanumeric.

Installation

bash
pnpm dlx structyl add one-time-password-field

API Reference

OneTimePasswordField.Root

An OTP / PIN input.

PropTypeDefault
lengthnumber

Number of digits.

6
valuestring

Controlled value.

onValueChange(value: string) => void

Called when the value changes.

type'numeric' | 'alphanumeric'

Allowed characters.

'numeric'
maskboolean

Mask the entered characters.

onComplete(value: string) => void

Called when all slots are filled.

OneTimePasswordField.Input

A single digit slot.

PropTypeDefault
indexnumber

Zero-based slot index.

OTP Field | structyl