All Projects → naveenvignesh5 → react-native-otp-textinput

naveenvignesh5 / react-native-otp-textinput

Licence: MIT license
Text View usable for OTP / Pin implementation

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-native-otp-textinput

DPOTPView
Customisable OTP view and Passcode view
Stars: ✭ 52 (-17.46%)
Mutual labels:  otp-view
react-native-floating-label-input
A customizable React Native TextInput with its placeholder always shown. Includes masks, global styles, character count, and a bunch else.
Stars: ✭ 206 (+226.98%)
Mutual labels:  textinput
react-textinput-chip
React library to generate textinput chip.
Stars: ✭ 14 (-77.78%)
Mutual labels:  textinput
rich input
Rich input box, implement @Someone and subject with color highlighting
Stars: ✭ 58 (-7.94%)
Mutual labels:  textinput
react-native-element-textinput
A react-native TextInput, TagsInput and AutoComplete component easy to customize for both iOS and Android.
Stars: ✭ 28 (-55.56%)
Mutual labels:  textinput
react-native-suggester
🔎 React-Native package to decorate TextInput and get suggestions with good UX
Stars: ✭ 52 (-17.46%)
Mutual labels:  textinput
textmatcher
A simple text watcher that matches specific targets like mention or hashtag in a string by defining rules
Stars: ✭ 67 (+6.35%)
Mutual labels:  textinputfield

REACT NATIVE OTP TEXT INPUT

React Native Component that can used for OTPs and Pins as secure pin input.

npm version npm downloads

Installation

npm i -S react-native-otp-textinput

Demo


How to Use

Please refer this repo on how to use the module in various scenarios.

Platform Support

Supports both Android and iOS.

Props

The following props are applicable for the component along with props supported by react native TextInput component

Prop Type Optional Default Description
defaultValue string Yes '' Default Value that can be set based on OTP / Pin received from parent container.
handleTextChange func No n/a callback with concated string of all cells as argument.
inputCount number Yes 4 Number of Text Input Cells to be present.
tintColor string Yes #3CB371 Color for Cell Border on being focused.
offTintColor string Yes #DCDCDC Color for Cell Border Border not focused.
inputCellLength number Yes 1 Number of character that can be entered inside a single cell.
containerStyle object Yes {} style for overall container.
textInputStyle object Yes {} style for text input.

Helper Functions

Clearing and Setting values to component

// using traditional ref
clearText = () => {
    this.otpInput.clear();
}

setText = () => {
    this.otpInput.setValue("1234");
}

render() {
    return (
        <View>
            <OTPTextInput ref={e => (this.otpInput = e)} >
            <Button title="clear" onClick={this.clearText}>
        </View>
    );
}
// hooks
import React, { useRef } from 'react';

const ParentComponent = () => {
    const otpInput = useRef(null);

    const clearText = () => {
        otpInput.current.clear();
    }

    const setText = () => {
        otpInput.current.setValue("1234");
    }

    return (
        <View>
            <OTPTextInput ref={e => (otpInput = e)} >
            <Button title="clear" onClick={clearText}>
        </View> ̰
    );
}

If you like the project

If you think I have helped you, feel free to get me coffee. 😊

Buy Me A Coffee

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].