1.0.6 • Published 7 months ago

react-native-split-input v1.0.6

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

react-native-split-input

otp input for react native

Installation

npm install react-native-split-input

Usage

import React, { useState } from 'react';
import(SafeAreaView) from 'react-native';
import SplitInput from 'react-native-split-input'

const App = () => {
  
  const [value,setValue]=useState<any>('')
  const handleTexChange=(val:any)=>{
   
      let reg=/^[0-9]{0,}$/
      console.log("reg",reg.test(val))
      if(reg.test(val)){
        setValue(val)
      
    }
  }

  return (
    <SafeAreaView style={{flex:1}}>
      <SplitInput
      digits={6}
      value={value}
      setValue={setValue}
      keyboardType={'numeric'}
      autoFocus={false}
      onChangeText={(val:any)=>handleTexChange(val)}
      focusBorderColor={'cyan'}
      focusBackgroundColor={'grey'}
      focusBorderWidth={2}
      
      />
      
    </SafeAreaView>
  );
};

export default App;

List of Available Props

Prop NameDefault ValueDescription
digits6Number of input fields (split digits)
value-The current input value
secureTextEntryfalseEnable secure text entry (e.g., for PIN entry)
ContentContainerStyle{}Style for the container of the entire component
inputContainerStyles{}Style for the container of individual input fields
inputStyle{}Style for each input field
keyboardType'default'Keyboard type for the input fields (e.g., 'numeric', 'email')
autoFocusfalseAutomatically focus the first input field
onChangeText-Callback function to handle text changes in the input fields
focusBorderWidth2Width of the border when an input field is focused
focusBorderColor-Color of the border when an input field is focused
focusBackgroundColor-Background color when an input field is focused
inputTextStyle{}Style for the text within the input fields

table is created with the ChatGPT

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

0.1.0

7 months ago

1.0.0

7 months ago