npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-verification-input

v4.2.0

Published

Customizable, masked input, which can be used for all sorts of codes.

Downloads

162,984

Readme

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) up to React 19. 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.

| Option | Type | Default | Description | | -------------- | -------- | -------------- |--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | value | String | - | 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. | | length | Number | 6 | Number of characters the input should allow. | | validChars | String | 'A-Za-z0-9' | Set of characters the input should allow. The string is inserted into a regexp character set ( /[]/ ) for input validation. | | placeholder | String | '·' (U+00B7) | The character to display in empty fields. In order to use the blank character as a placeholder, specify this option as ' ' or ''. | | autoFocus | Boolean | false | Focus the input automatically as soon as it is rendered. | | passwordMode | Boolean | false | Hide the input value by displaying * instead. | | passwordChar | String | '*' | Custom character to be displayed when passwordMode is true | | inputProps | Object | {} | The properties of this object get forwarded as props to the input element. In particular, you can use this prop to assign an id attribute to the input field to connect it to a label element. Use aria-label for internationalization of the input field. | | containerProps | Object | {} | The properties of this object get forwarded as props to the container element. | | classNames | Object | {} | Object with CSS class names to add to the specified elements. Supported elements (= object-keys) are container, character, characterInactive, characterSelected, characterFilled | | onChange | Function | - | Callback function that gets called with the string value whenever it changes. | | onComplete | Function | - | Callback function that gets called with the string value when the input is fully filled. | | onFocus | Function | - | Callback function that gets called when the component obtains focus. | | onBlur | Function | - | 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.