Input OTP

One-time-code field on bits-ui PinInput. The active cell lifts into the focus ring and a caret blinks inside the empty slot — paste fills every cell in one move.

Usage

value = —

States

Disabled

Invalid

Pattern

Pass a pattern prop to restrict which characters are accepted. The example below allows digits only.

Separator

Use InputOTP.Separator between groups for visual grouping — defaults to a dash icon.

Controlled

Bind external $state to read or reset the value from outside the component.

value = —

Form

Compose InputOTP inside a Field for label + validation message — the invalid state propagates into each Slot's ring colour.

API reference

Inherits bits-ui PinInput.Root props via spread. Children are a snippet of cell descriptors — compose with Group, Slot, and Separator.

PropTypeDescription
string (bindable)Concatenated code across cells. Two-way bindable.
numberTotal digits in the code. Split across groups as needed.
(value: string) => voidFires when every cell is filled.
booleanDisables every cell and drops opacity to 50%.
HTMLInputElement | nullTwo-way-bindable hidden-input reference.
stringMerged onto the root via tailwind-merge.