
Company News
Socket Named Top Sales Organization by RepVue
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.
react-native-otp-textinput
Advanced tools
React Native Component that can used for OTPs and Pins as secure pin input.
npm i -S react-native-otp-textinput

Check the Example react native app for usage.
Supports both Android and iOS.
The following props are applicable for the component along with props supported by react native TextInput component
| Prop | Type | Optional | Default | Description |
|---|---|---|---|---|
| defaultValue | string | Yes | '' | Default Value that can be set based on OTP / Pin received from parent container. |
| handleTextChange | func | No | n/a | callback with concated string of all cells as argument. |
| handleCellTextChange | func | Yes | n/a | callback for text change in individual cell with cell text and cell index as arguments |
| inputCount | number | Yes | 4 | Number of Text Input Cells to be present. |
| tintColor | string | Yes | #3CB371 | Color for Cell Border on being focused. |
| offTintColor | string | Yes | #DCDCDC | Color for Cell Border Border not focused. |
| inputCellLength | number | Yes | 1 | Number of character that can be entered inside a single cell. |
| containerStyle | object | Yes | {} | style for overall container. |
| textInputStyle | object | Yes | {} | style for text input. |
| testIDPrefix | string | Yes | 'otpinput' | testID prefix, the result will be otp_input_0 until inputCount |
| autoFocus | bool | Yes | false | Input should automatically get focus when the components loads |
Clearing and Setting values to component
// using traditional ref
clearText = () => {
this.otpInput.clear();
}
setText = () => {
this.otpInput.setValue("1234");
}
render() {
return (
<View>
<OTPTextInput ref={e => (this.otpInput = e)} >
<Button title="clear" onClick={this.clearText}>
</View>
);
}
// hooks
import React, { useRef } from 'react';
const ParentComponent = () => {
let otpInput = useRef(null);
const clearText = () => {
otpInput.current.clear();
}
const setText = () => {
otpInput.current.setValue("1234");
}
return (
<View>
<OTPTextInput ref={e => (otpInput = e)} >
<Button title="clear" onClick={clearText}>
</View>
);
}
If you think I have helped you, feel free to get me coffee. 😊
FAQs
Textview usable for OTP implementation
The npm package react-native-otp-textinput receives a total of 7,377 weekly downloads. As such, react-native-otp-textinput popularity was classified as popular.
We found that react-native-otp-textinput demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket won two 2026 Reppy Awards from RepVue, ranking in the top 5% of all sales orgs. AE Alexandra Lister shares what it's like to grow a sales career here.

Security News
NIST will stop enriching most CVEs under a new risk-based model, narrowing the NVD's scope as vulnerability submissions continue to surge.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.