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

@input-kit/pin

v0.1.0

Published

PIN/OTP input component

Readme

@input-kit/pin

A React component library for PIN and OTP input fields with full keyboard navigation, paste support, and accessibility features.

Features

  • PIN Input - Numeric-only input for PIN codes
  • OTP Input - Alphanumeric support for OTP codes
  • Auto-focus - Automatically focuses next input
  • Paste Support - Paste full code from clipboard
  • Backspace Handling - Smart backspace navigation
  • Masking - Show or hide input with password type
  • Validation - Custom validation support
  • Keyboard Navigation - Arrow keys, Home, End support
  • Accessible - Full ARIA support
  • Headless Hook - Build custom inputs with usePinInput

Installation

npm install @input-kit/pin

Quick Start

PIN Input

import { PinInput } from '@input-kit/pin';

function App() {
  const [pin, setPin] = useState('');

  return (
    <PinInput
      length={4}
      value={pin}
      onChange={setPin}
      mask
      onComplete={(code) => console.log('PIN:', code)}
    />
  );
}

OTP Input

import { OtpInput } from '@input-kit/pin';

function App() {
  const [otp, setOtp] = useState('');

  return (
    <OtpInput
      length={6}
      value={otp}
      onChange={setOtp}
      alphanumeric
      onComplete={(code) => verifyOtp(code)}
    />
  );
}

usePinInput Hook

import { usePinInput } from '@input-kit/pin';

function CustomPinInput() {
  const { values, handlers, inputRefs, clear, isComplete } = usePinInput({
    length: 6,
    onComplete: (code) => console.log('Complete:', code),
  });

  return (
    <div>
      {values.map((char, index) => (
        <input
          key={index}
          ref={(el) => { inputRefs.current[index] = el; }}
          value={char}
          onChange={(e) => handlers.onChange(index, e)}
          onKeyDown={(e) => handlers.onKeyDown(index, e)}
          onPaste={(e) => handlers.onPaste(index, e)}
          onFocus={(e) => handlers.onFocus(index, e)}
        />
      ))}
      <button onClick={clear}>Clear</button>
      {isComplete && <span>Complete!</span>}
    </div>
  );
}

API Reference

PinInput Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | length | number | required | Number of input characters | | value | string | required | Current value | | onChange | (value: string) => void | required | Callback when value changes | | onComplete | (value: string) => void | - | Callback when all inputs filled | | mask | boolean | false | Whether to mask the input | | placeholder | string | '' | Placeholder character | | disabled | boolean | false | Whether the input is disabled | | readOnly | boolean | false | Whether the input is read-only | | validate | (char: string) => boolean | - | Custom validation function | | className | string | '' | Custom class for container | | inputClassName | string | '' | Custom class for each input | | autoFocus | boolean | false | Auto-focus first input on mount |

OtpInput Props

Same as PinInput, plus:

| Prop | Type | Default | Description | |------|------|---------|-------------| | alphanumeric | boolean | false | Allow alphanumeric characters |

usePinInput Options

| Option | Type | Default | Description | |--------|------|---------|-------------| | length | number | required | Number of input characters | | value | string | '' | Current value | | onChange | (value: string) => void | - | Callback when value changes | | onComplete | (value: string) => void | - | Callback when all inputs filled | | alphanumeric | boolean | false | Allow alphanumeric characters | | validate | (char: string) => boolean | - | Custom validation function | | autoFocus | boolean | false | Auto-focus first input on mount |

usePinInput Return

| Property | Type | Description | |----------|------|-------------| | values | string[] | Array of individual character values | | setValue | (index: number, value: string) => void | Set value at specific index | | setValues | (value: string) => void | Set entire value | | clear | () => void | Clear all inputs | | isComplete | boolean | Whether all inputs are filled | | handlers | Object | Event handlers for inputs | | inputRefs | RefObject<(HTMLInputElement \| null)[]> | Refs for input elements | | focusInput | (index: number) => void | Focus a specific input |

Keyboard Navigation

  • Arrow Left/Right - Navigate between inputs
  • Backspace - Delete current character, move back if empty
  • Delete - Delete current character
  • Home - Focus first input
  • End - Focus last input
  • Ctrl+V - Paste full code

Custom Styling

Both components accept className and inputClassName props for styling:

<PinInput
  length={4}
  value={pin}
  onChange={setPin}
  className="my-container"
  inputClassName="my-input"
/>
.my-container {
  display: flex;
  gap: 0.5rem;
}

.my-input {
  width: 3rem;
  height: 3.5rem;
  text-align: center;
  font-size: 1.5rem;
  border: 2px solid #ddd;
  border-radius: 0.5rem;
}

.my-input:focus {
  border-color: #007acc;
  outline: none;
}

Custom Validation

// Only allow even digits
<PinInput
  length={4}
  value={pin}
  onChange={setPin}
  validate={(char) => ['0', '2', '4', '6', '8'].includes(char)}
/>

TypeScript

Full TypeScript support is included:

import type { 
  PinInputProps, 
  OtpInputProps, 
  UsePinInputOptions,
  PinInputRef,
  OtpInputRef 
} from '@input-kit/pin';

Browser Support

  • Chrome/Edge 88+
  • Firefox 78+
  • Safari 14+

License

MIT