Input OTP
A one-time password input pairing a single native text editor with indexed display slots, paste/autofill support, and form integration.
Base Input OTP provides a one-time code input backed by a single native text editor—preserving native selection, paste, deletion, one-time-code autofill, and IME composition—while rendering each character in passive Slot readouts.
Preview
Section titled “Preview” Web Components React Vue Vue 2
Loading interactive preview… The article and source are ready to read. Interactive controls will appear here when ready.
Installation
Section titled “Installation”Available starting in 0.3.0-rc.1 and later releases.
Anatomy
Section titled “Anatomy”Compose Root, Input (or Control inside a form), Slot, and Separator:
Root: managesvalue/defaultValue, codelength(1–32, default6),pattern('numeric'or'alphanumeric'),disabled,readOnly,name, andariaLabel.Input: single underlying text editor that strips disallowed characters and enforceslengthonce composition settles. EmitsvalueChangeon edits andcompletedonce for each accepted full-length code.Slot: passive,aria-hiddenreadout indexed byindexwithout adding extra editors or Tab stops. When the editable input is focused, active slot highlights track the real caret or selected range.Control(form integration): useControlinstead ofInputinsideField/FormFieldto connectFieldLabel, validation, form serialization, and reset.
Root Props
Section titled “Root Props”Passing value selects controlled mode.
| Prop | Type | Default |
|---|---|---|
value | string | — |
defaultValue | string | '' |
length | number | 6 |
pattern | 'numeric' 'alphanumeric' | numeric |
disabled | boolean | false |
readOnly | boolean | false |
name | string | '' |
ariaLabel | string | One-time code |
Other parts
Section titled “Other parts”- Input: optional
placeholder(no default). - Slot:
indexdefaults to0. - Control, Separator: no props.