Socket
Socket
Sign inDemoInstall

react-number-format

Package Overview
Dependencies
8
Maintainers
1
Versions
117
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-number-format

React component to format number in an input or as a text.


Version published
Maintainers
1
Created

Package description

What is react-number-format?

The react-number-format package is a React component designed for formatting number input fields. It allows users to format numbers as currency, percentages, decimals, phone numbers, credit card numbers, and other custom formats. It also supports features like custom prefix, suffix, and thousand separator, masking, and custom formatting.

What are react-number-format's main functionalities?

Number Formatting

This feature allows you to format numbers with thousands separators and add a prefix. In this example, the number 2456981 is formatted as currency with a dollar sign prefix and commas as thousand separators, displayed as $2,456,981.

import NumberFormat from 'react-number-format';

<NumberFormat value={2456981} displayType={'text'} thousandSeparator={true} prefix={'$'} />

Custom Format

This feature enables custom formatting for inputs. Here, the format prop defines the pattern for a phone number and the mask prop is used for placeholder characters, allowing users to enter a phone number in the format ###-###-####.

import NumberFormat from 'react-number-format';

<NumberFormat format="###-###-####" mask="_" />

Currency Formatting

This feature is used to format input as currency. It includes a thousand separator, a dollar sign prefix, and ensures that there are always two decimal places.

import NumberFormat from 'react-number-format';

<NumberFormat thousandSeparator={true} prefix={'$'} decimalScale={2} fixedDecimalScale={true} />

Other packages similar to react-number-format

Readme

Source

Actions Status

react-number-format

React Number format is a input formatter library with a sophisticated and lightweight caret engine.

Features

  1. Prefix, suffix and thousand separator.
  2. Custom pattern formatting.
  3. Masking.
  4. Custom formatting handler.
  5. Format number in an input or format as a simple text.
  6. Fully customizable

Install

npm

Using npm

npm install react-number-format

Using yarn

yarn add react-number-format
ES6

Numeric Format

import { NumericFormat } from 'react-number-format';

Pattern Format

import { PatternFormat } from 'react-number-format';

Read the full documentation here

https://s-yadav.github.io/react-number-format/docs/intro

Migrate from v4 to v5

https://s-yadav.github.io/react-number-format/docs/migration

v4 doc

v4 Docs

Development

  • Clone the repository or download the zip
  • npm i -g yarn to download Yarn
  • yarn to install dependencies
  • yarn start to run example server (http://localhost:8084/)
  • yarn test to test changes
  • yarn build to bundle files
Testing

Test cases are written in jasmine and run by karma

Test files : /test/**/*.spec.js

To run test : yarn test

Keywords

FAQs

Last updated on 14 May 2023

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