OTP Input

A field for one-time passwords and verification codes, entered one digit per cell, with autofill.

import { OTPInput } from "@plexui/react-native"

Examples

Overview

Platforms

iOS 26Android
Native componentNone: a text field for a one-time code, drawn as the Plex cellsNone: the Plex Android code boxes
Look44 by 52pt capsule cells, a dot in an empty cell, the outline darkening on focus32.7 by 40.8dp outlined boxes with 4dp corners, the line in the accent on focus

API

PropTypeDefaultDescription
lengthnumber6Number of digit cells
valuestring—Controlled value
onChange(value: string) => void—Called when value changes
onComplete(value: string) => void—Called when all digits filled
groupingnumber[]—Grouping pattern with extra gap (e.g. [3,3])
invalidbooleanfalseInvalid visual state
errorMessagestring—Error message below the input
disabledbooleanfalseDisable all cells
autoFocusbooleanfalseAuto-focus first cell on mount
aria-labelstring—Names the code ("Verification code"): the cells' group on the web, and the start of each cell's name on iOS and Android ("Verification code, digit 1 of 6"), where a group is not announced
labelstring—The same name as aria-label
digitLabel(index: number, length: number) => stringDigit 1, or digit 1 of 6 once the code is namedThe name of a cell, for another language
styleStyleProp<ViewStyle>—Style of the root
testIDstring—Test id of the root; each cell's field takes it with -digit-1, -digit-2 and so on

Each digit stays in its own cell: typing into a later empty cell keeps the digit there, and clearing a cell in the middle does not move the others. The value is the filled digits in order. Pasting or typing several digits writes them from the focused cell onward.