1.1.0 β€’ Published 4 months ago

react-native-otp-manager v1.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
4 months ago

Here’s a well-structured README.md file for your package:


react-native-otp-manager πŸ”’

πŸš€ Fast, Smooth, and Lag-Free OTP Input for React Native!

Overview

react-native-otp-manager is a lightweight and customizable OTP input component for React Native. It ensures a seamless and lag-free experience for OTP entry, making verification faster and more efficient.

Features

βœ… Smooth and lag-free input
βœ… Highly customizable UI
βœ… Auto-focus and OTP autofill support
βœ… Works with React Native CLI & Expo
βœ… Dark mode support


Installation

Using npm

npm install react-native-otp-manager

Using yarn

yarn add react-native-otp-manager

Usage

Basic Example

import React from "react";
import { View } from "react-native";
import OTPManager from "react-native-otp-manager";

const App = () => {
  const handleComplete = (otp: string) => {
    console.log("Entered OTP:", otp);
  };

  return (
    <View>
      <OTPManager maxLength={6} onComplete={handleComplete} />
    </View>
  );
};

export default App;

Props

PropTypeDescriptionDefault
maxLengthnumberNumber of OTP digits4
onCompletefunctionCallback when OTP is completely enterednull
onChangefunctionCallback when OTP changesnull
containerStyleobjectCustom styles for the outer container{}
inputStyleobjectCustom styles for OTP input fields{}
focusedInputStyleobjectCustom styles for the focused input field{}

Customization

You can easily style the OTP input fields using containerStyle, inputStyle, and focusedInputStyle.

Example with Custom Styles

<OTPManager
  maxLength={6}
  onComplete={(otp) => console.log("OTP:", otp)}
  containerStyle={{ marginTop: 20 }}
  inputStyle={{ borderColor: "#FF5733", color: "#FF5733" }}
  focusedInputStyle={{ borderColor: "#FFC300", backgroundColor: "#FFF5E1" }}
/>

Contributing

Pull requests are welcome! If you find any issues or want to suggest improvements, feel free to open an issue or contribute.