Package Exports
- react-currency-input-field
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (react-currency-input-field) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
React Currency Input Field Component
Features:
- Only allows numbers
- Can handle decimals
- Can add prefix eg. £ or $
- Automatically inserts commas
- Lightweight and simple
- Works well with Bootstrap styling
Install
npm install react-currency-input-field
or
yarn add react-currency-input-field
Usage
import CurrencyInput from 'react-currency-input-field'
<CurrencyInput
id="input-example"
name="input-name"
placeholder="£1,000"
defaultValue={1000}
allowDecimals={true}
decimalsLimit={2}
onChange={(value, name) => {process(value, name)}}
/>
Have a look in src/examples
for more examples on implementing.
Props
Name | Type | Default | Description |
---|---|---|---|
allowDecimals | boolean |
true |
Allow decimals |
id | string |
Component id | |
name | string |
Component (input) name | |
className | string |
Class names | |
decimalsLimit | number |
2 |
Limit length of decimals allowed |
defaultValue | number |
Default value | |
disabled | boolean |
false |
Disabled |
onChange | function |
Handle change in value | |
placeholder | string |
Placeholder if no input | |
prefix | string |
Include a prefix eg. £ or $ | |
maxLength | number |
Maximum number of characters the user can enter |
Issues
Feel free to message me if you have any questions