1.0.1 • Published 2 months ago

react-native-expo-opt-input v1.0.1

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

Installation

bun add react-native-expo-opt-input
yarn add react-native-expo-opt-input
npm install --save react-native-expo-opt-input

Dependencies

NOTES:

We use expo-clipboard to handle the clipboard in this package, So you should install expo-clipboard

npx expo install expo-clipboard

Basic Usage

import OTPInputView from 'react-native-expo-opt-input';

<OTPInputView pinCount={4} />

More Advanced Usage

import * as React from 'react';

import { StyleSheet, View } from 'react-native';
import OTPInputView from 'react-native-expo-opt-input';

export default function App() {
  return (
    <View style={styles.container}>
      <OTPInputView
        placeholderCharacter=""
        codeInputFieldStyle={{
          borderColor: 'black',
          borderWidth: 2,
          color: 'gray',
        }}
        returnKeyType="done"
        style={{ width: 200 }}
        pinCount={4}
      />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
  box: {
    width: 60,
    height: 60,
    marginVertical: 20,
  },
});

Parameters

ParameterrequiredDescription
pinCountYESNumber of digits in the component
codeNOYou can use this library as a controlled / uncontrolled component by supplying this prop or not
codeInputFieldStyleNOThe style of the input field which is NOT focused
codeInputHighlightStyleNOThe style of the input field which is focused
autoFocusOnLoadNOAuto activate the input and bring up the keyboard when component is loaded
onCodeChangedNOCallback when the digits are changed
onCodeFilledNOCallback when the last digit is entered
secureTextEntryNOHide contents of text fields
editableNOSet editable for inputs
keyboardAppearanceNOKeyboard appearance ('default', 'dark', 'light')
keyboardTypeNOKeyboard type
clearInputsNOClear inputs after entering code
placeholderCharacterNOThe character/string that will be used as placeholder in the individual code input fields
placeholderTextColorNOColor of the placeholderCharacter

Roadmap

  • Typescript definition file
  • Typescript implementation
  • Add basic unit tests
  • Add integration tests