/react-format

💵 A React Component to make formatting money/currency and dates easier 📅

Primary LanguageTypeScriptMIT LicenseMIT

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>