Socket
Socket
Sign inDemoInstall

react-intl-number-input

Package Overview
Dependencies
8
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-intl-number-input

A React component for masked and formatted number input.


Version published
Weekly downloads
107
decreased by-39.55%
Maintainers
1
Install size
11.9 kB
Created
Weekly downloads
 

Readme

Source

react-intl-number-input

A React component for masked and formatted number input.

Demo

Install

npm install react-intl-number-input

Usage

import React from 'react'
import { render } from 'react-dom';
import IntlNumberInput from 'react-intl-number-input';

class App extends React.Component {
  constructor(props) {
    super(props);

    this.state = {
      value: 0,
      maskedValue: 0,
    }

    this.handleChange = this.handleChange.bind(this);
  }

  handleChange(event, value, maskedValue) {
    event.preventDefault();
    this.setState({ value, maskedValue });
  }

  render() {
    return (
      <div>
        <p>
          <IntlNumberInput onChange={this.handleChange} />
        </p>
        <p>
          value: {this.state.value}
        </p>
        <p>
          maskedValue: {this.state.maskedValue}
        </p>
      </div>
    );
  }
}

render(<App />, document.getElementById("root"));

Properties

NameTypeDefault ValueDescription
valuenumber or string0Initial numeric value
localestring'en-US'BCP 47 language tag. Defines a language code and a country or region code.
Intl Locale Identification e.g. 'de-DE', 'pt-BR' and 'ja-JP'
prefixstring''String used as prefix for the masked value
suffixstring''String used as suffix for the masked value
precisionnumber2Number of fraction digits to use
onChangefunctionn/a(event, value, maskedValue) => {}
Callback function to handle value changes

Examples

    // maskedValue: 1,234,567.89
    <IntlNumberInput />
    // maskedValue: 12,345.6789
    <IntlNumberInput precision={4} />
    // maskedValue: $1,234,567.89
    <IntlNumberInput prefix="$" />
    // maskedValue: 1,234%
    <IntlNumberInput suffix="%" precision={0} />
    // maskedValue: R$ 1.234.567,89
    <IntlNumberInput
      locale="pt-BR"
      prefix="R$ "
      precision={2}
    />

Keywords

FAQs

Last updated on 23 May 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc