Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

eng-naveed/react-native-otp-input-box

Repository files navigation

πŸ” react-native-otp-box-input

npm version license issues stars

A simple, customizable, and powerful OTP (One-Time Password) input component for React Native. Designed to provide a smooth OTP entry experience on both iOS and Android.

Whether you’re implementing mobile number verification, secure logins, or any OTP-based flow, this component gives you full control over the UI and behavior of OTP fields.

πŸ“Έ Demo

Demo

πŸ“¦ Installation

Install the package using npm or yarn:

yarn add react-native-otp-box-input

OR

npm install react-native-otp-box-input

πŸ“š Table of Contents


✨ Features

  • πŸ”’ Dynamic OTP input fields (any length)
  • ⚑ Auto-focus & intelligent navigation
  • 🎨 Custom styling for inputs and container
  • 🧩 Plug-and-play usage with advanced customization
  • πŸ“± Works perfectly on both Android and iOS
  • πŸ› οΈ Support for placeholder, render customization, and focus callbacks

πŸš€ Usage

A basic example of how to use the component:

import React from 'react';
import { View } from 'react-native';
import OtpInputBox from 'react-native-otp-box-input';
const MyComponent = () => (
 <View>
 <OtpInputBox
 length={6}
 onChangeOtp={(otp) => console.log('Entered OTP:', otp)}
 autoFocus={true}
 />
 </View>
);

βš™οΈ Props

Prop Type Default Description
length number Required Number of OTP input boxes to display
onChangeOtp (otp: string) => void Required Callback that receives the full OTP string as the user types
autoFocus boolean false Automatically focuses the first input when the component mounts
keyboardType 'default', 'numeric', 'number-pad', etc. 'numeric' Keyboard type for each input box
placeholder string undefined Placeholder text for all input boxes
placeholders string[] undefined Individual placeholders for each input field
style ViewStyle undefined Custom style for the input container
inputStyle StyleProp<ViewStyle> undefined Style for each individual input field
activeInputStyle StyleProp<ViewStyle> undefined Additional style for the currently focused input
renderInput ({ ...props }) => React.ReactNode undefined Custom render function to fully override the input UI
inputProps TextInputProps {} Additional props to pass to each TextInput
onInputFocus (index: number) => void undefined Callback when an input field gains focus
onInputBlur (index: number) => void undefined Callback when an input field loses focus

πŸ‘€ Author

Made with ❀️ by Naveed Khan


πŸ“„ License

This project is licensed under the MIT License.


🀝 Contributing

Contributions, issues, and feature requests are welcome!
Feel free to open an issue or submit a pull request.


🏷 Tags

react-native-otp otp-input otp sms-verification authentication react-native-component typescript

Releases

No releases published

Packages

No packages published

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /