All Projects → jsillitoe → React Currency Input

jsillitoe / React Currency Input

Licence: mit
React component for inputing currency amounts

Programming Languages

javascript
184084 projects - #8 most used programming language
es6
455 projects

Projects that are alternatives of or similar to React Currency Input

Currency
Handles currency calculations, storage etc
Stars: ✭ 109 (-37.71%)
Mutual labels:  currency
Cryptocurrency Portfolio
Google Sheets automatic creation with Google Apps Script (GAS) for managing a cryptocurrency tracking spreadsheet with multi exchanges
Stars: ✭ 134 (-23.43%)
Mutual labels:  currency
Ngx Currency
📦 Currency mask module for Angular
Stars: ✭ 161 (-8%)
Mutual labels:  currency
Moeda
💰 📈 A foreign exchange rates and currency conversion using CLI
Stars: ✭ 113 (-35.43%)
Mutual labels:  currency
Frankfurter
💱 Currency data API
Stars: ✭ 123 (-29.71%)
Mutual labels:  currency
Easymoney
Library for operating with monetary values in JavaScript and Typescript 💵
Stars: ✭ 145 (-17.14%)
Mutual labels:  currency
Javamoney Lib
JavaMoney financial libraries, extending and complementing JSR 354
Stars: ✭ 104 (-40.57%)
Mutual labels:  currency
Cash Cli
💰💰 Convert currency rates directly from your terminal!
Stars: ✭ 168 (-4%)
Mutual labels:  currency
Exchanger
🏢 Currency exchange rates framework for PHP
Stars: ✭ 133 (-24%)
Mutual labels:  currency
Decimal for cpp
Decimal data type for C++
Stars: ✭ 159 (-9.14%)
Mutual labels:  currency
Getme
CLI utility for everyday tasks. With getme you get weather, forecast, currency rate, upload files, IP address, word definitions, text translations, internet speed, do google searches, get inspirational quotes and get Chuck Norris jokes
Stars: ✭ 118 (-32.57%)
Mutual labels:  currency
Sample Currency Converter
A sample currency conversion Progressive Web App
Stars: ✭ 119 (-32%)
Mutual labels:  currency
Track Ip
Advanced Ip Tracker Tool
Stars: ✭ 150 (-14.29%)
Mutual labels:  currency
Nanocurrency Js
🔗 A toolkit for the Nano cryptocurrency, allowing you to derive keys, generate seeds, hashes, signatures, proofs of work and blocks.
Stars: ✭ 113 (-35.43%)
Mutual labels:  currency
Currency.js
A javascript library for handling currencies
Stars: ✭ 2,214 (+1165.14%)
Mutual labels:  currency
Currency
A beautiful currency conversion app written in Kotlin and using Anko. Supports multi-theme with dynamic switching effect.
Stars: ✭ 107 (-38.86%)
Mutual labels:  currency
Django Prices
Django fields for the prices module
Stars: ✭ 135 (-22.86%)
Mutual labels:  currency
Thenextquant
Asynchronous driven quantitative trading framework.
Stars: ✭ 172 (-1.71%)
Mutual labels:  currency
Jackson Datatype Money
Extension module to properly support datatypes of javax.money
Stars: ✭ 165 (-5.71%)
Mutual labels:  currency
Ng Currency
Currency with AngularJS made easy!
Stars: ✭ 156 (-10.86%)
Mutual labels:  currency

react-currency-input

An ES2015 react component for currency. Supports custom decimal and thousand separators as well as precision.

Build Status

Changes

v1.3.0:

  • Deprecated "onChange" option in favor of "onChangeEvent". This fixes the argument order to better match React's default input handling
  • Updated dependencies to React 15
  • Added parseFloat polyfill
  • Persist events to deal with an issue of event pooling
  • Other bug fixes.

Installation

npm install react-currency-input --save

Integration

You can store the value passed in to the change handler in your state.

import React from 'react'
import CurrencyInput from 'react-currency-input';

const MyApp = React.createClass({
    getInitialState(){
        return ({amount: "0.00"});
    },

    handleChange(event, maskedvalue, floatvalue){
        this.setState({amount: maskedvalue});
    },
    render() {
        return (
            <div>
                <CurrencyInput value={this.state.amount} onChangeEvent={this.handleChange}/>
            </div>
        );
    }
});
export default MyApp

You can also assign a reference then access the value using a call to getMaskedValue().

import React from 'react'
import CurrencyInput from 'react-currency-input';

const MyApp = React.createClass({
    handleSubmit(event){
        event.preventDefault();
        console.log(this.refs.myinput.getMaskedValue())
    },
    render() {
        return (
            <form onSubmit={this.handleSubmit}>
                <CurrencyInput ref="myinput" />
            </form>
        );
    }
});
export default MyApp

Separators and Precision

Specify custom decimal and thousand separators:

    // 1.234.567,89
    <CurrencyInput decimalSeparator="," thousandSeparator="." />

Specify a specific precision:

    // 123,456.789
    <CurrencyInput precision="3" />
    // 123,456,789
    <CurrencyInput precision="0" />

Currency

Optionally set a currency symbol as a prefix or suffix

    // $1,234,567.89
    <CurrencyInput prefix="$" />
    // 1,234,567.89 kr
    <CurrencyInput suffix=" kr" />

Negative signs come before the prefix

    // -$20.00
    <CurrencyInput prefix="$" value="-20.00" />

All other attributes are applied to the input element. For example, you can integrate bootstrap styling:

    <CurrencyInput className="form-control" />

Options

Option Default Value Description
value 0 The initial currency value
onChange n/a Callback function to handle value changes. Deprecated, use onChangeEvent.
onChangeEvent n/a Callback function to handle value changes
precision 2 Number of digits after the decimal separator
decimalSeparator '.' The decimal separator
thousandSeparator ',' The thousand separator
inputType "text" Input field tag type. You may want to use number or tel*
allowNegative false Allows negative numbers in the input
allowEmpty false If no value is given, defines if it starts as null (true) or '' (false)
selectAllOnFocus false Selects all text on focus or does not
prefix '' Currency prefix
suffix '' Currency suffix
autoFocus false Autofocus

*Note: Enabling any mask-related features such as prefix, suffix or separators with an inputType="number" or "tel" could trigger errors. Most of those characters would be invalid in such input types.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].