An enhanced Numeric Input made with React
Docs: https://react-enhanced-numeric-input.netlify.app/
To install the component, just type:
npm install react-enhanced-numeric-input
or
yarn add react-enhanced-numeric-input
To use it, you will need to import the component and use it like:
import NumericInput from "react-enhanced-numeric-input";
<NumericInput />
<NumericInput decimalPrecision={2} value={50} />
The new version includes some default styles to format the money and percent input. To use it, it is necessary to import the styles in the project distribution pack.
import "react-enhanced-numeric-input/dist/react-enhanced-numeric-input.css";
It is possible to set some properties globally.
Some properties need to be set systemwide. To do so, it is necessary to import the function that defines it and set a new value.
Property | Default Value |
---|---|
moneyMask | $ |
percent | % |
decimalSeparator | , |
thousandSeparator |
import {
setDefaultMoneyMask,
setDefaultPercent,
setDefaultDecimalSeparator,
setDefaultThousandSeparator,
} from "react-enhanced-numeric-input";
setDefaultMoneyMask("US$");
setDefaultPercent("percent");
setDefaultDecimalSeparator(".");
setDefaultThousandSeparator(",");
Property | Type | Default Value |
---|---|---|
className | string | - |
decimalPrecision | number | 0 |
disabled | boolean | false |
maxLength | number | 20 |
id | string | - |
name | string | - |
placeholder | string | - |
onChange | function | - |
onBlur | function | - |
onClick | function | - |
onFocus | function | - |
onKeyPress | function | - |
style | string | - |
value | string or number | - |
percent | boolean | false |
money | boolean | false |
stringValueOnBlur | boolean | false |
decimalSeparator | string | , |
thousandSeparator | string | |
moneyMask | string | $ |