Skip to Content
ARCUI

InputOTP

Controlled 4–8 cell one-time-code input with numeric/alphanumeric validation, secure presentation, focus control, and completion callbacks.

InputOTP is a controlled one-time-code field.

Usage

const [code, setCode] = useState("");

<InputOTP
  value={code}
  onValueChange={setCode}
  onComplete={(completedCode) => verify(completedCode)}
/>

Length

length defaults to 6 and must be an integer from 4 through 8.

The controlled value cannot contain more characters than the configured length.

Character set

Built-in modes:

numeric       -> 0–9
alphanumeric  -> 0–9, A–Z, a–z
<InputOTP
  type="alphanumeric"
  value={code}
  onValueChange={setCode}
/>

type defaults to "numeric".

Custom character validation

allowedChars replaces the character set derived from type and is evaluated per character:

<InputOTP
  value={code}
  onValueChange={setCode}
  allowedChars={/[A-F0-9]/i}
/>

Stateful g and y RegExp flags are handled safely by ARCUI.

Completion

onComplete runs when the controlled value becomes a complete valid OTP. The same code can complete again after first becoming incomplete.

blurOnComplete defaults to false and can release focus after successful completion.

Secure presentation

<InputOTP secure value={code} onValueChange={setCode} />

Secure mode uses native secure text presentation for entered characters.

Focus

autoFocus focuses the first available cell after mount.

The public ref exposes:

type TInputOTPRef = {
  focus: () => void;
  blur: () => void;
};

focus() targets the first empty cell, or the last cell when the code is complete.

State and native props

disabled is the fully disabled semantic state. active={false} keeps ARCUI's inactive presentation while preventing interaction.

InputOTP exposes supported native TextInput props such as keyboard/autocomplete/accessibility configuration, while locking props that would conflict with OTP ownership, cell geometry, validation, and manual ARCUI font scaling.

Testing

Use testID where the public component contract exposes it so application tests can target the ARCUI-owned root without depending on visual implementation details. Component-specific stable descendants may use documented suffixes.

For provider setup and the dedicated react-native-arc-ui/testing entrypoint, see Testing.

API Reference

Also inherits: TextInputProps

PropTypeDefaultDescription
ref?Ref<TInputOTPRef>—Imperative InputOTP API.
valuestringrequiredControlled OTP value.
onValueChange(value: string) => voidrequiredCalled whenever ARCUI resolves a new valid OTP value.
onComplete?(value: string) => void—Called whenever the controlled value becomes a complete valid OTP. The same code can complete again after first becoming incomplete.
length?number6Number of OTP cells. Must be an integer between 4 and 8.
secure?booleanfalseUses native secure text presentation for entered characters.
autoFocus?booleanfalseFocuses the first available cell after mount.
blurOnComplete?booleanfalseBlurs InputOTP after a complete valid code is resolved.
type?TInputOTPType"numeric"Semantic OTP character set. numeric: 0-9 alphanumeric: 0-9, A-Z, a-z
allowedChars?RegExp—Optional per-character validation override. When supplied, this replaces the character set derived from `type`. Stateful `g` and `y` flags are handled safely by ARCUI.
label?string——
error?string——
disabled?booleanfalseFully disabled semantic state.
active?booleantrueWhether the field participates in the current interaction flow.
style?StyleProp<ViewStyle>—Root component style.
testID?string——

Generated from the ARCUI 1.1.x TypeScript source snapshot. Native inherited props remain available through the referenced React Native surface.

The generated table above covers ARCUI-owned public props from the source-aligned type snapshot. Native inherited surfaces remain available where the public type extends React Native props.

Motion

Cell focus/error/disabled presentation uses ARCUI/Reanimated visual state while the actual OTP string remains controlled React state.

See Motion for the library-wide model.

Performance

Keep application semantics at normal React update cadence. ARCUI components avoid using React state as a frame-by-frame animation driver; use the component callbacks and let Reanimated own continuous visual work.

See Performance for broader guidance.

Accessibility

ARCUI uses native roles, labels, semantic accessibility state, centralized font scaling, and localizable ARCUI-owned strings where the component owns behavior text. Consumer accessibility overrides remain available when they do not conflict with component correctness.

See Accessibility for the library-wide model.

Theming

This component resolves its normal presentation from ARCUI tokens and active theme context. Prefer token configuration for system-wide design changes and component props for genuine instance-level exceptions.

Relevant token areas include:

colors.*.inputOTP
sizings.inputOTP
radius.inputOTP
border.inputOTP
typography.inputOTP
animations

Top-level token overrides are shallow. Compose changed built-in namespaces from defaultTokens rather than relying on recursive merge behavior.

See Tokens and Theming.

Try it live

Open the existing React Native Snack to explore InputOTP interactively.

Open in Expo Snack ↗

On this page