Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

A simple React component that renders a numeric input field with a calculator that pops up on focus.

License

NotificationsYou must be signed in to change notification settings

silviajoy/react-calculator-input

Repository files navigation

A simple React component that renders a numeric input field with a calculator that pops up on focus.

DEMO

Set Up

Install the package

npm install react-calculator-input

and import the css in your application

import '[path_to_node_modules_folder]/react-calculator-input/lib/index.scss'

or copy it in your own file, you can find thescss there.

Usage

Import the component

import NumericInput from 'react-calculator-input'

To use it, you need to set theid prop, which will be theid attribute of theinputtag in thehtml (and thefor attribute of thelabel tag, if any).

Other props you can play with:

PropProp TypeRequiredDefault
idStringRequired
initialValuenumber0
nameString
classNameString
labelString
labelPosition["bottom", "top"]"top"
labelClassNameString
calculatorBackgroundString"#666"
calculatorKeyColorString"#ccc"
format["float", "integer"]"float"


id
The value of this prop will be theid attribute of theinput tag and of thefor attribute of thelabel tag, if any.

initialValue
The initialvalue attribute of theinput tag. Default is 0.

name
The value of this prop will be thename attribute of theinput tag.

className
The value of this prop will be theclass attribute of theinput tag.

label
The value of this prop will be the content of thelabel tag.If you want an empty label, just type in the empty string"" .

labelPosition
Define the position of thelabel tag in the html order. It can be either"top" or"bottom". The default value is"top". If you setlabelPosition="bottom" thehtml will look something like this:

<input type="number"><label for="myinput"> Age </label>

labelClassName
The value of this prop will be theclass attribute of thelabel tag.

calculatorBackground
You should pass acss color property to this prop and you can set the background color of the calculator that pops up oninput focus. Default color is#666

calculatorKeyColor
You should pass acss color property to this prop either. In this case you decide the color of the keypad keys. Default color is#ccc.

format
With this prop you decide if the input value will accept"float"ing point numbers or"integer"s only. Default value is"float".

Example

<NumericInput label="Age" name="age"/>

will result in the following html:

<div>    <label for="myinput">Age</label>    <input type="number" name="age" value="0">    <!-- calculator stuff --></div>

About

A simple React component that renders a numeric input field with a calculator that pops up on focus.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors3

  •  
  •  
  •  

Languages


[8]ページ先頭

©2009-2026 Movatter.jp