1.0.9 • Published 10 months ago

custom-react-native-otp-input v1.0.9

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

custom-react-native-otp-input

A simple and light reusable react native component to accept otp input. It is fully customizable, and written purely in Typescript.

Installation

Supported React Native version: >=0.59.0

npm install custom-react-native-otp-input

Or

yarn add custom-react-native-otp-input

After installation, navigate to the ios folder and run

pod install

Basice Usage

import React,{useState} from 'react';
import { SafeAreaView, StyleSheet, Text } from 'react-native'
import OtpInput from 'custom-react-native-otp-input'

const App = () => {
  const [otp, setOtp] = useState<string>('')
  
  return (
    <SafeAreaView style={styles.safeAreaContainer}>
      <Text>
        Other Components.....
      </Text>
      <OtpInput
        value={(val) => setOtp(val)}
        numberOfDigits={4}
        inputShape={'box'}
        secureEntry
      />
    </SafeAreaView>
  );
}

export default App;

const styles = StyleSheet.create({
  safeAreaContainer: {
    alignItems: 'center',
    justifyContent: 'center',
    height: '100%',
    width: '100%',
  }
})

API Reference

PropertyTypeRequiredDescriptionDefault
valuecallbackyesreturns the value as the user typesvoid
numberOfDigitsnumbernoThe number of input fields (currently takes between 4 and 8)6
inputShapestringnoA string to describe desired shape of the input fieldcircle
secureEntrybooleannoDecide whether to show input or hidefalse
includeAlphabetsbooleannoDecide wether to accept letters as inputfalse
styleobjectnoAdd custom style to the component rapper{}
itemStyleobjectnoAdd cutom style the input rapper{}
1.0.9

10 months ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago