Skip to content
TrademarkTrademark
Docs
Form Controls

OTPInput

Updated: September 14, 2026
View on GitHub

OTPInput collects a one-time code as separate boxes rather than one field. It moves focus as digits are typed, accepts a pasted code into all boxes at once, and calls onComplete the moment the last one is filled.

Unlike the other inputs here it does not extend Input — it is a group of fields, not one, so it has its own small surface.

Screen readers and autofill

The boxes are one group, named "One-time code", and each box says which digit it is ("OTP digit 2 of 6"). The first box asks the browser for a code from a text message (autocomplete="one-time-code"), and a whole code arriving at once, by autofill or paste, fills every box. With error, every box is invalid and described by errorMessage. Name the group with aria-label, or translate both names with labels.

API reference

Type
Default
length
How many digits, and so how many boxes.
number4
onComplete
Called with the full code once the last box is filled.
(code: string) => void—
error
Put the group in its error state.
booleanfalse
errorMessage
Message shown under the boxes when error is set.
React.ReactNode—
disabled
Block input across every box.
booleanfalse
autoFocus
Focus the first box on mount. Leave it off if the code is not the first thing on the page.
booleanfalse
labels
The group's and the boxes' accessible names, to translate them.
OTPInputLabels—
Edit this page on GitHub