2.0.0 • Published 5 years ago

pin-input v2.0.0

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

React PINInput

React PINInput component .

Installation

npm i --save pin-input

Usage

Numeric Input

<PINInput
          type='number'
          fields={4}
        />

Text input:

<PINInput
          type='text'
          fields={4}
        />

Password input:

<PINInput
          type='password'
          fields={4}
        />

Password input with numeric input type:

<PINInput
          type='password'
          inputType='number'
          fields={4}
        />

Password input with showing last typed input value:

<PINInput
          type='password'
          inputType='number'
          showLastTypedValue={true}
          fields={4}
        />

Passing filter key codes and characters :

<PINInput
          type='text'
          fields={4}
          filterKeyCodes={[189, 190]}
          filterChars= {['-', '.']}
        />

Passing class for input wrapper div and for input:

<PINInput
          type='text'
          fields={4}
          inputClassName={'pin-input'}
          inputWrapperClassName={'pin-input-wrapper'}
        />

Passing default value

<PINInput
          type='text'
          fields={4}
          value={'1111'}
        />

Passing readOnly param

<PINInput
          type='text'
          fields={4}
          readOnly={true}
        />

Pass callback functions

const someFunction = () =>{
  
}

<PINInput
          type='text'
          fields={4}
          onChange={someFunction}
          onKeyDown={someFunction}
        />

Props:

Property TypeDescription
typestringOnly types like: text, number, password are accepted.
inputTypestringThe inputType prop you can set with the type="password" for accepting password type (number or text)
fieldsnumberAllowed amount of characters to enter.
valuestringSetting the initial value of code input field.
onChangefuncFunction, which is called whenever there is a change of value in the input box.
onKeyDownfuncFunction, key down call back function
inputClassNamestringAdd classname to the input element.
inputWrapperClassNamestringAdd classname to the div element.
readOnlyboolWhen present, it specifies that the element should be disabled. 
autoFocusboolSetup autofocus on the first input, true by default. 
filterKeyCodesarrayFilter characters on key down.
filterCharsarrayFilter characters.default: '-', '.'
patternstringThe pattern prop specifies a regular expression that the element's value is checked against.

License

MIT