1.0.7 • Published 11 months ago

react-native-verification-code-input v1.0.7

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

React Native Verification Code Input

A highly customizable verification code input component for React Native and Expo applications. Perfect for OTP (One-Time Password), authentication codes, and verification processes. By default, it accepts only numeric input, making it ideal for PIN codes and OTP verification. Supports SMS auto-fill on both iOS and Android platforms.

Now you can buy me coffee

📱 Demo

iOS Demo

iOS Demo

Android Demo

Android Demo

✨ Features

  • 🎨 Fully customizable appearance
    • Custom input box sizes and padding
    • Customizable border colors for different states
    • Flexible text styling
    • Error state handling with custom colors
  • 📱 Smart input handling
    • SMS auto-fill support for iOS and Android
    • Paste support for verification codes
    • Numeric input by default (customizable)
    • Automatic focus on the first input
    • Seamless navigation between inputs
    • Backspace support for easy editing
    • Keyboard type customization
  • 🔢 Flexible configuration
    • Customizable number of input boxes
    • Support for different input lengths
    • Container and input level styling
  • 🎯 Developer friendly
    • Written in TypeScript
    • Full type definitions
    • Compatible with Expo and React Native CLI
    • Minimal dependencies
  • ⚡️ Performance optimized
    • Efficient re-rendering
    • Minimal memory footprint

📦 Installation

# Using npm
npm install react-native-verification-code-input
# Using yarn
yarn add react-native-verification-code-input
# Using pnpm
pnpm add react-native-verification-code-input

🚀 Quick Start

IOS https://github.com/user-attachments/assets/f7134b8f-fd21-46c3-8bea-b7580e2491a5 ANDROID https://github.com/user-attachments/assets37fbc293-eb60-40b1-81a5-16db6c87f92f

import { VerificationCodeInput } from 'react-native-verification-code-input';

const VerificationScreen = () => {
  const handleComplete = (code) => {
    console.log('Entered code:', code);
    // Validate the code here
  };

  return (
    <VerificationCodeInput
      length={6}
      onComplete={handleComplete}
      error={false}
      errorColor="#FF3B30"
      borderColor="#E5E5E5"
      activeBorderColor="#007AFF"
      inputSize={45}
      inputPadding={10}
    />
  );
};

📱 SMS Auto-fill Support

The component automatically supports SMS auto-fill functionality:

  • iOS: Uses textContentType="oneTimeCode" for automatic SMS code detection
  • Android: Uses autoComplete="sms-otp" for SMS auto-fill support
  • Paste Support: Users can paste the entire code, and it will be automatically distributed across the inputs

No additional configuration is needed - it works out of the box!

🛠 Props

PropTypeDefaultDescription
lengthnumber6Number of input boxes
onCompletefunction-Callback when all digits are entered
autoFocusbooleantrueAuto focus first input on mount
errorbooleanfalseShow error state
containerStyleViewStyle-Style for the container
inputStyleViewStyle-Style for each input box
textStyleTextStyle-Style for the input text
errorColorstring'#FF3B30'Color for error state
borderColorstring'#E5E5E5'Default border color
activeBorderColorstring'#007AFF'Border color when focused
inputSizenumber45Size of each input box
inputPaddingnumber10Padding inside input boxes
keyboardTypeKeyboardTypeOptions'numeric'Keyboard type for input ('numeric', 'default', etc.)

🎨 Styling Examples

Custom Theme

<VerificationCodeInput
  length={4}
  inputSize={50}
  containerStyle={{
    gap: 15,
  }}
  inputStyle={{
    borderRadius: 12,
    backgroundColor: '#F5F5F5',
  }}
  textStyle={{
    fontSize: 24,
    fontWeight: 'bold',
  }}
  borderColor="#DDD"
  activeBorderColor="#4CAF50"
  errorColor="#F44336"
/>

Dark Theme

<VerificationCodeInput
  length={6}
  containerStyle={{
    backgroundColor: '#1A1A1A',
  }}
  inputStyle={{
    backgroundColor: '#2D2D2D',
    borderRadius: 8,
  }}
  textStyle={{
    color: '#FFFFFF',
  }}
  borderColor="#3D3D3D"
  activeBorderColor="#BB86FC"
  errorColor="#CF6679"
/>

📱 Platform Support

  • iOS
  • Android
  • Expo

🤝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check issues page.

📝 License

This project is MIT licensed.

📦 Repository

You can find the source code on GitHub.

1.0.7

11 months ago

1.0.6

11 months ago

1.0.5

11 months ago

1.0.4

11 months ago

1.0.3

11 months ago

1.0.0

11 months ago