react-input-currency

Install
npm install --save react-input-currency
Usage
import React, { Component } from 'react'
import InputCurrency from 'react-input-currency'
class Example extends Component {
constructor() {
super();
this.state = {
value: '20',
}
}
render () {
return (
<InputCurrency
value={this.state.value}
onChange={({ value }) => this.setState({ value })}
/>
);
}
}
Styling
If you want the text aligned right:
.style {
text-align: right;
}
...
<InputCurrency className={style} {...props} />
Props
| Parameter |
Type |
Description |
| value |
string/number |
Field value. |
| id |
string |
Field id. |
| name |
string |
Field name. |
| required |
boolean |
Html5 required |
| onChange |
function |
Callback function called when value changes, returns an object { name: props.name, value: masked input value } |
| className |
string |
Jsx className |
Mask props
| Parameter |
Default |
Type |
| decimal |
. |
string |
| prefix |
$ |
string |
| thousands |
, |
string |
Example
const maskProps = {
decimal: ',',
prefix: 'R