New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

react-formatted-currency

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-formatted-currency

React component for displaying parts of the currency value differently

  • 0.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

React formatted currency

What is this?

This is a React component which uses format-currency-as-parts, which allows parts of the formatted currency to be styled differently, e.g. smaller decimals, different coloured currency code.

Installation

Yarn

$ yarn add react-formatted-currency

NPM

$ npm install react-formatted-currency

Usage

import FormattedCurrency from 'react-formatted-currency';

const CurrencyComponent = () => (
  <FormattedCurrency
    amount={123456.789}
    currency="USD"
    locale="en-us"
    parts={['code', 'number']}
    render={({ code, number }) => (
      <div>
        <span>{code}</span>
        <strong>{number}</strong>
      </div>
    )}
  />
);
  • amount (required, number): The number to format
  • currency (required, string): 3-letter ISO 4217 currency code (https://en.wikipedia.org/wiki/ISO_4217)
  • parts (required, string[]): An array of parts you want to display:
    • number: the whole number
    • integer: the integer portion of the number
    • decimals: the fraction portion of the number (including the decimal point), will return empty string if number of decimals for the currency is 0 (e.g. JPY).
    • code: the currency code
    • symbol: the currency symbol (Latin form when approriate)
  • locale (required, string): The locale to format the number with
  • render (required, function): Render the formatted currency; an object with the properties - code, symbol, number, integer, and/or decimals is provided to the render prop depending on what is passed through the parts prop.

See examples in the examples folder.

Keywords

FAQs

Package last updated on 14 May 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc