react-format
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

React Format codecov npm version

A React Component to make formatting money/currency easier

Installation

npm i react-format --save

Usage

// First import an available formatting component
import { Money } from 'react-format';
 
// Then use it
<Money locale="en-US" currency="USD">3400</Money>
// This renders $3,400.00

API

Available Formatting Components

Money
<Money
  /*
   * This is an optional string with the code for the locale.
   * This defaults to "en-US"
   */
  locale="en-US"
  /*
   * This is an optional string with the code for the currency.
   * This defaults to "USD"
   */
  currency="USD"
>
{/* The child should be the number you want formatted */}
</Money>
Date
<Date
  /*
   * This is an optional string with the code for the locale.
   * This defaults to "en-US"
   */
  locale="en-US"
  /*
   * This is an optional object with options that you can pass in.
   * This defaults to an empty object.
   */
  options={}
>
  {/* The child should be the date you want formatted */}
</Date>

Package Sidebar

Install

npm i react-format

Weekly Downloads

43

Version

1.2.0

License

MIT

Last publish

Collaborators

  • divyagnan