Pin Input

OTP and PIN entry with auto-advance, smart backspace, and paste spreading.

Paste works too — try it.

Import#

import { PinInput } from "astralis-ui";

Usage#

Typing advances to the next box, Backspace at an empty box steps back and clears, and pasting a full code spreads it across the boxes. onChange receives the combined string on every keystroke; onComplete fires once every box is filled — the natural hook for auto-submitting a verification code.

Masking, types and sizes#

masked, 6 digits, filled
alphanumeric, size lg

Props#

PropTypeDefaultDescription
lengthnumber4Number of boxes.
value / defaultValue / onChangestring / string / (value: string) => void— / "" / —The combined code.
onComplete(value: string) => voidFires when all boxes are filled.
type"numeric" | "alpha" | "alphanumeric""numeric"Character validation.
maskbooleanfalseBullet display, password-style.
variant / size"outline" | "filled" / "sm" | "md" | "lg""outline" / "md"Styling.
placeholderstring"○"Shown in empty boxes.
autoFocusbooleanfalseFocus the first box on mount.
invalid / disabled / readOnlybooleanfalseState flags — inherited from Field.

Keyboard#

KeyAction
type a characterFill the box and advance to the next
BackspaceClear the box; if already empty, move back and clear that one
DeleteClear the current box (no movement)
/ Move between boxes without clearing
pasteDistribute the pasted characters across the boxes

Accessibility#

Each box is a real input with a per-cell label ("digit 1 of 4"), reachable with Tab/Shift-Tab; focusing a box selects its content so typing replaces.