Forms

Input OTP

@xui/input-otp

A segmented one-time-code / PIN field. A single hidden input drives the row, so native caret, paste and one-time-code autofill all work. value is two-way bindable; completed fires when every slot is filled.

Install

pnpm add @xui/input-otp

Add the barrel to a standalone component's imports:

import { XuiInputOtpImports } from '@xui/input-otp';

@Component({
  imports: [XuiInputOtpImports],
  // …
})

Examples

Basic

Loading preview…

Four digits

Loading preview…

Masked

Loading preview…

Alphanumeric

Loading preview…

API

XuiInputOtp

componentxui-input-otp

A segmented one-time-code / PIN field. A single hidden input drives the whole row — so native caret, selection, paste and autofill (one-time-code) all work — while the visible slots render each character. value is two-way bindable; completed fires once every slot is filled.

Inputs

NameTypeDefaultclassClassValueExtra classes, merged into the component's own rather than replacing them.''lengthnumberHow many characters the code has, and so how many slots are drawn.6valuetwo-waystringThe code entered so far — a single string, not one value per slot. Two-way bindable with [(value)].''disabledbooleanBlock entry and dim the slots.falseinputType'numeric' | 'text'numeric restricts entry to digits and asks for the numeric keypad; text accepts anything.'numeric'maskbooleanRender each filled slot as a dot instead of the character.false

Outputs

NameTypecompletedstringFired once every slot is filled.

Source

libs/ui/input-otp/xui

xUI 2.0.0 — Apache 2.0 licensed. Built with Angular and Tailwind CSS.