1.0.1 • Published 6 months ago

verify-code-input-react v1.0.1

Weekly downloads
-
License
-
Repository
github
Last release
6 months ago

verify-code-input-react

React component to insert a code (number, text, password) in a sigle input elements

verify-code

NPM JavaScript Style Guide

Install

npm i verify-code-input-react

or

yarn add verify-code-input-react

or

pnpm i verify-code-input-react

Usage

1 . Require verify-code-input-react after installation

import { InputCode } from 'verify-code-input-react';

2 . Include verify-code-input-react as in the following example

use ref

import React, { useRef } from 'react';
import { InputCode } from 'verify-code-input-react';

const App = () => {
  const ref = useRef('');

  const handleClick = () => {
    console.log(ref.current.value);
  };

  return (
    <>
      <InputCode ref={ref} fields={6} placeholder='-' type='text' placeholder={'-'} />
      <button onClick={handleClick}>submit</button>
    </>
  );
};

use onTriggerChange function

import React, { useState } from 'react';
import { InputCode } from 'verify-code-input-react';

const App = () => {
  const [value, setValue] = useState<string>('');

  const handleClick = () => {
    console.log(value);
  };

  return (
    <>
      <InputCode
        fields={6}
        onKeyDownInput={() => {}}
        onTriggerChange={setValue}
        placeholder='-'
        type='text'
        placeholder={'-'}
      />
      <button onClick={handleClick}>submit</button>
    </>
  );
};

Props

Contributors

MIT © StanTran

1.0.1

6 months ago

0.1.10

6 months ago

0.1.9

6 months ago

0.1.8

6 months ago

0.1.7

6 months ago

0.1.6

6 months ago

0.1.5

6 months ago

0.1.4

6 months ago

0.1.3

6 months ago

0.1.2

6 months ago

0.1.1

6 months ago

0.1.0

6 months ago