1.0.10 • Published 6 years ago

react-input-currency v1.0.10

Weekly downloads
6
License
MIT
Repository
github
Last release
6 years ago

react-input-currency

NPM JavaScript Style Guide

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

ParameterTypeDescription
valuestring/numberField value.
idstringField id.
namestringField name.
requiredbooleanHtml5 required
onChangefunctionCallback function called when value changes, returns an object { name: props.name, value: masked input value }
classNamestringJsx className

Mask props

ParameterDefaultType
decimal.string
prefix$string
thousands,string
Example
const maskProps = {
	decimal: ',',
	prefix: 'R$',
	thousands: '.'
}

<InputCurrency {...maskProps}  />

Will give the mask R$ 2.500,00

License

MIT © alom2

1.0.10

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago