Edit pageTiny react component that wraps the ECMAScript Internationalization API with sane defaults to work with numbers and currencies.
Features
- Effortless format numbers and currencies for different locales
- Relies in the standard Intl.NumberFormat constructor
- Possibility to use it as an standalone React Component using props to configure it
- Possibility to use a general config using a React Context Provider
- Detects automatically the browser language as a default locale
- Exposes a function to update the Provider config
- Ability to render a number or a currency with any html tag
- Props match Intl.NumberFormat constructor arguments
Support
Installation
Usage
This is the easiest way to use Number
or Currency
formatter components:
You don't even need to pass a locale
prop, by default it will try guess the locale from the browser.
Check the Recipes page to see the recommended way to use it and other advanced topics.Possible imports
You can import several things from react-intl-number-format
, let's check the possibilities:
Number
Component to format numbersCurrency
Component to format currenciesIntlProvider
to set a global configurationuseIntl
hook to update the configuration