Socket
Socket
Sign inDemoInstall

react-digit-input

Package Overview
Dependencies
Maintainers
2
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-digit-input

Higher Order Component for pass code/separated digit input.


Version published
Weekly downloads
8.4K
increased by7.68%
Maintainers
2
Weekly downloads
 
Created

Readme

Source

react-digit-input

React hook to handle inputs with separated boxes for each digit.

  • Live Demo
  • Demo source: html, TypeScript

Build Status Rolling Versions NPM version

Installation

npm install react-digit-input --save

Usage

import * as React from 'react';
import * as ReactDOM from 'react-dom';
import useDigitInput from 'react-digit-input';

function App() {
  const [value, onChange] = React.useState('');
  const digits = useDigitInput({
    acceptedCharacters: /^[0-9]$/,
    length: 6,
    value,
    onChange,
  });
  return (
    <div>
      <div className="input-group">
        <input inputMode="decimal" autoFocus {...digits[0]} />
        <input inputMode="decimal" {...digits[1]} />
        <input inputMode="decimal" {...digits[2]} />
        <span className="hyphen" />
        <input inputMode="decimal" {...digits[3]} />
        <input inputMode="decimal" {...digits[4]} />
        <input inputMode="decimal" {...digits[5]} />
      </div>
      <pre>
        <code>"{value}"</code>
      </pre>
    </div>
  );
}

ReactDOM.render(<App />, document.getElementById('root'));

License

MIT

FAQs

Package last updated on 22 Jul 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc