4.1.2 โ€ข Published 29 days ago

react-verification-input v4.1.2

Weekly downloads
650
License
MIT
Repository
github
Last release
29 days ago

logo

npm npm downloads Lint and Test npm bundle size

react-verification-input is a customizable, masked input that can be used to enter all sorts of codes e.g. security codes when two-factor authenticating. Also I'm sure you can think of many more creative use cases.

Demo

๐Ÿ”ด Try it out yourself!

Features

โšก Get Started Easily: The component works out of the box without the need to pass it a single prop.

๐Ÿ›  Highly Configurable: Change the behaviour of the component to fit your needs by passing props.

๐Ÿ’…๐Ÿผ Custom Styling: Customize the component's styling to match the look of your application.

๐Ÿ‘จ๐Ÿผโ€๐Ÿ’ป TypeScript Support: The package contains TypeScript declarations so you can enjoy IntelliSense in your editor.

โœ… Compatibility: Compatible with React 16 (>=16.8.0), React 17 and React 18. Support of new versions of React as they are released will be ensured.

Getting Started

First, install the package using npm or yarn.

Now, import the React component like this:

import VerificationInput from "react-verification-input";

And in your JSX write:

<VerificationInput />

That's it! You now have a basic verification input with default configuration rendered on your page. ๐ŸŽ‰๐Ÿ˜ƒ

The component accepts a variety of props, which allow to configure the component according to your needs. For a complete API overview see here.

API Documentation

All of these props are optional and some also come with a default value. However, it's recommended to use at least the length, validChars and onChange/onComplete props.

OptionTypeDefaultDescription
valueString-The value of the verification input. Behaves like the value prop of a regular input element. This is necessary if the value needs to be changed from the outside (e.g. clearing the value). If you pass this prop, you are responsible to manage the value state. Otherwise the state will be kept inside the component.
lengthNumber6Number of characters the input should allow.
validCharsString'A-Za-z0-9'Set of characters the input should allow. The string is inserted into a regexp character set ( /[]/ ) for input validation.
placeholderString'ยท' (U+00B7)The character to display in empty fields. In order to use the blank character as a placeholder, specify this option as ' ' or ''.
autoFocusBooleanfalseFocus the input automatically as soon as it is rendered.
passwordModeBooleanfalseHide the input value by displaying * instead.
inputPropsObject{}The properties of this object get forwarded as props to the input element.
containerPropsObject{}The properties of this object get forwarded as props to the container element.
classNamesObject{}CSS class names to add to the specified elements.
onChangeFunction-Callback function that gets called with the string value whenever it changes.
onCompleteFunction-Callback function that gets called with the string value when the input is fully filled.
onFocusFunction-Callback function that gets called when the component obtains focus.
onBlurFunction-Callback function that gets called when the component loses focus.

Custom Styling

Style the input by passing it your custom class names like so:

<VerificationInput
  classNames={{
    container: "container",
    character: "character",
    characterInactive: "character--inactive",
    characterSelected: "character--selected",
    characterFilled: "character--filled",
  }}
/>

Example

๐Ÿ”ด View live example!

Component Structure

The following illustration shows the component structure.

Contributing

Contributions welcome โค๏ธ. If you want to contribute, feel free to have a look at the contribution guide.

4.1.2

29 days ago

4.1.1

2 months ago

4.1.0

4 months ago

4.0.0

6 months ago

4.0.0-beta.1

6 months ago

4.0.0-beta.0

6 months ago

3.3.1

10 months ago

3.2.0

1 year ago

3.1.3

1 year ago

3.3.0

1 year ago

3.1.2

1 year ago

3.1.1

2 years ago

3.1.0

2 years ago

3.0.0-beta.1

2 years ago

2.0.8-beta.0

2 years ago

3.0.0-beta.0

2 years ago

3.0.0-beta.3

2 years ago

3.0.0-beta.2

2 years ago

2.0.7

2 years ago

2.0.8

2 years ago

3.0.0

2 years ago

2.0.6-beta.0

2 years ago

2.0.5

2 years ago

2.0.6

2 years ago

2.0.4

2 years ago

2.0.3

3 years ago

2.0.2

3 years ago

2.0.0-beta.9

3 years ago

2.0.0-beta.8

3 years ago

2.0.0-beta.7

3 years ago

2.0.1-beta.0

3 years ago

2.0.0-beta.6

3 years ago

2.0.0-beta.5

3 years ago

2.0.1

3 years ago

2.0.0-beta.4

3 years ago

2.0.0

3 years ago

2.0.0-beta.3

3 years ago

2.0.0-beta.10

3 years ago

2.0.0-beta.2

4 years ago

2.0.0-beta.1

4 years ago

0.1.5

6 years ago

0.1.4

6 years ago

0.1.3

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.7

6 years ago

0.0.6

6 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago

1.5.0

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago