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 🙏

© 2026 – Pkg Stats / Ryan Hefner

react-pin-component

v0.2.2

Published

A simple pin input component for React

Readme

A Simple React Pin Component inspired by React Pin Input. This has types included and is React v18 supported.

This allows for full customization on the input type rendered, meaning you can use any UI library to style your components.

Install

yarn add react-pin-component
npm install react-pin-component.

Pin Props

| Property | Type | Description | |----------------|------------------|-----------------------------------------------------------------------------------------------------| | length | number | Length of the pin | | validate | Function | This function is used to validate the inputs and should return a boolean. | | regexCriteria | RegExp | A regex string to check the input by. | | initialValue | number | string | The initial value to be loaded into the pin input. This does not have to match the length property. | | style | CSSProperties | Additional style properties to add or override to the pin component | | focus | boolean | Choosing whether or not to focus on the first input when rendered | | onChange | Function | This function outputs the current pin and a completed boolean. | | addSplit | Object | Pass in {component: JSX.Element, every: number} to add a splitting character. | | inputOptions | Object | See table below, this gives options to specify for the input element | | InputComponent | ReactElement | Include a custom component or <input /> into here to choose what kind of input is rendered. |

Input Options

| Property | Type | Description | |--------------------------|---------------|-------------------------------------------------------------------------------| | debug | boolean | Opt to include or hide console logs related to the validate and regex checks. | | removeDefaultInputStyles | boolean | Removing the styles that come with this package on the input component | | inputFocusStyle | CSSProperties | Custom styles that are only rendered when the input is in focus. |

Example

import React from 'react';
import PinComponent from 'react-pin-component';

const MfaTokenInput = () => (
  <PinComponent

    // defined length for the pin. This will render a specific number of input boxes.
    length={6}

    // You can choose to take effect on the completed pin here, but also have access to the pin along the way.
    onChange={(pin, completed) => console.log({ pin, completed })}

    // Loading the initial value, but it's not required to be the same length as the pin itself.
    initialValue={87}

    // A simple function to check the values match. All values come out as strings.
    validate={(value) => Number(value) < 8}

    // Full regex strings supported. This will check if the number validates above AND if it passes the regex string
    // you do not need to use both, just different ways to use it.
    regexCriteria={/^[0-9]*$/}

    // styles for the entire pin component
    style={{
      backgroundColor: 'lightgrey',
    }}

    InputComponent={
      <input 
        style={{
          backgroundColor: 'darkgrey',
          borderRadius: '50%',
          margin: '5px',
        }}
        inputMode="numeric"
        pattern="^[a-zA-Z0-9]+$"
        autoComplete='off'
      />
    }

    inputOptions={{
      // styles to be send and shown only when an input box is in focus.
      inputFocusStyle: {
        border: '2px solid blue',
        // If you want to remove the browser focus outline set this.
        outline: 0,
      },
      debug: true
    }}

    // Adds a divider component into the pin input every 3 values.
    addSplit={{
      component: <h1>-</h1>,
      every: 5,
    }}
  />
);

export default MfaTokenInput;