A simple, lightweight, and customizable React component for displaying localized currency values using the browser's Intl.NumberFormat API.
- π Supports any locale and currency via Intl.NumberFormat
- βοΈ Optional control over decimal precision
- π‘ Null-safe rendering
- βοΈ Tiny, tree-shakable React component
npm install react-currency-formatter-liteyarn add react-currency-formatter-lite
import React from 'react';
import { CurrencyFormatter } from 'react-currency-formatter-lite';
const App = () => {
return (
<div>
<CurrencyFormatter value={1234.56} />
<CurrencyFormatter value={1234.56} currency="EUR" locale="de-DE" />
<CurrencyFormatter value={1234.56} currency="JPY" decimalPrecision={0} />
</div>
);
};
| Prop | Type | Default | Description |
|---|---|---|---|
value |
number | null |
required | The numeric value to format |
decimalPrecision |
number |
2 |
Number of decimal places |
locale |
string |
"en-US" |
BCP 47 locale string for localization |
currency |
string |
"USD" |
ISO 4217 currency code (e.g. USD, EUR, JPY) |
<CurrencyFormatter value={1234.56} currency="EUR" locale="de-DE" />
// β¬1.234,56
MIT License Β© Victor Olayemi