A react component for digit inputs

Overview

digitinputs-react

NPM JavaScript Style Guide

A react component for digit inputs. It might be very useful to get SMS codes from user on two factor authentications and in many other scenarios when you need get an numerical input from user digit by digit.

Visit homepage to see examples.

Install

npm install --save digitinputs-react

Usage

Pass a function with single paramater to onDigitsChange props to get values. Digits lenght depends on how many Digit component passed as child. You can switch between text & password inputs by using hidden switch prop.

import React, { Component } from 'react'

import { DigitInputs, Digit } from 'digitinputs-react'
import 'digitinputs-react/dist/index.css'

class Example extends Component {
  // ...

  handleDigitsChange(value) {
    value.asNumber // -> 123
    value.asString // -> '123'
    value.asObject //-> { '0': '1', '1': '2', '2': '3'}
  }

  // ...
  render() {
    return (
      <form>
        <DigitInputs hidden onDigitsChange={this.handleDigitsChange}>
          <Digit />
          <Digit />
          <Digit />
        </DigitInputs>
      </form>
    )
  }
}

And you can pass custom className to override default styles on DigitInputs & Digit components

... ) } ">
function Example() {
  return (
    <DigitInputs className="custom-digitinputs">
      <Digit className="digit-one" />
      ...
    </DigitInputs>
  )
}

License

MIT © yyalim

You might also like...
A React component that let's you mention people in a textarea like you are used to on Facebook or Twitter.

React Mentions A React component that let's you mention people in a textarea like you are used to on Facebook or Twitter. Used in production at Signav

Time-input - A keyboard friendly react component for capturing time

time-input A keyboard friendly react component for capturing time features small UI surface area (just a form input) keyboard friendly (can type times

A fully customizable, one-time password input component for the web built with React

block-code A fully customizable, one-time password input component for the web built with React Live demo Highlights Easy to use Fully customizable Re

International phone number input component for react

Welcome to react-contact-number-input 👋 International phone number input component for react Install npm install react-contact-number-input Author 👤

A ReactJS component that allows for multiple text field input, built using the FluentUI library
A ReactJS component that allows for multiple text field input, built using the FluentUI library

A ReactJS component that allows for multiple text field input, built using the FluentUI library

A ReactJS input component that manages multiple languages
A ReactJS input component that manages multiple languages

React-translatable-input A ReactJS input component that manages multiple languages. $ npm install --save react-translatable-input Demo http://belkalab

A React Hook & Container to help with payment card input fields.
A React Hook & Container to help with payment card input fields.

React Payment Inputs A React Hook & Container to help with payment card input fields. React Payment Inputs Demos Requirements Installation Usage With

Input mask for React, Angular, Ember, Vue, & plain JavaScript
Input mask for React, Angular, Ember, Vue, & plain JavaScript

⚠️ This library is not maintained. Pull-requests and issues are not monitored. Alternatives to text-mask include: https://github.com/uNmAnNeR/imaskjs

A numpad for number, date and time, built with and for React.

React numpad A numpad for number, date and time, built with and for React. It's written with the extensibility in mind. The idea of this project is to

Comments
  • Hi

    Hi

    I want to have focus on inputs initially - But there is no any Example or guide in docs - I found isFocused - and focused props on code - but it is hard to figure out how to use it properly -

    if you add an example in doc I would really thank you . thanks for your attentions

    opened by mehran-dev 1
Owner
Yusuf Yalım
A teacher, web developer, samurai wannabe. Loves oldschool games, movies, music and science-fiction books
Yusuf Yalım
React Input Format & Mask, tiny (≈800b) component to transform any input component into formatted or masked input. Supports number, date, phone, currency, credit card, etc

RIFM - React Input Format & Mask Is a tiny (≈ 800b) component (and hook) to transform any input component into formatted or masked input. Demo Highlig

RealAdvisor 1.3k Dec 13, 2022
Input masking component for React. Made with attention to UX.

react-input-mask Input masking component for React. Made with attention to UX. This is a development branch for version 3.0. For the latest stable ver

Nikita Lobachev 2.1k Dec 30, 2022
Masked input React component

MaskedInput A React component for input masking, built on top of inputmask-core. Live Demo Install npm npm install react-maskedinput --save Browser

Jonny Buchanan 721 Nov 30, 2022
React component for entering and validating PIN code.

React component for entering and validating PIN code.

Konstantin Kulinicenko 287 Dec 18, 2022
React Currency Input Field Component

React Currency Input Field Component

Chun 357 Dec 30, 2022
Headless phone number input component for React. Because phone numbers are hard.

React Headless Phone Input A headless phone number input component built for usability. Phone numbers are hard. Users expect to be able to enter phone

Ben Aubin 26 Nov 16, 2022
A fully customizable, one-time password input component for the web built with React.

react-otp-input A fully customizable, one-time password input component for the web built with React. Live Demo CodeSandbox Installation To install th

Devfolio 402 Dec 30, 2022
A React component that decorates it's children with mouse/touch position tracking, a status toggle fired by click/gesture events, and more.

A React component that decorates it's children with mouse/touch position tracking, a status toggle fired by click/gesture events, and more.

Adam Risberg 37 Jun 17, 2022
React component that handles csv file input and its parsing

react-csv-reader React component that handles csv file input. It handles file input and returns its content as a matrix. Docs: nzambello.github.io/rea

Nicola Zambello 180 Dec 26, 2022
React component for international phone number input

react-phone-number-input International phone number input for React. See Demo Install npm install react-phone-number-input --save If you're not us

Nikolay 837 Dec 21, 2022