Amount
An amount of money given as integer minor units and an ISO 4217 code, written by @sdxc/money in any locale.
€12,840.56
Money in+€2,100.00
Money out€23.40
Yen¥84,500
German1.299,50 €
Compact$12.5K
View code
<Amount value={1284056} currency="EUR" locale="en-IE" smallMinor />
<Amount value={210000} currency="EUR" sign="ledger" />
<Amount value={-2340} currency="EUR" sign="ledger" />
<Amount value={84500} currency="JPY" />
<Amount value={129950} currency="EUR" locale="de-DE" />
<Amount value={1250000} currency="USD" compact />Installation
An ordinary dependency: install it, import the theme once, and import the component where it is used.
npm add @sdxc/ui remiximport "@sdxc/ui/theme.css";Or copy it into your project to edit it:
sdxc ui add amountUsage
import { Amount } from "@sdxc/ui";Renders an amount in a native <data> element whose value is the decimal figure, so a
script or a crawler reads the number while a person reads the formatted one. Figures are
tabular, so a column of amounts lines up, and the amount never wraps.
Examples
<Amount value={4500} currency="GBP" sign="ledger" /><Amount value={1284056} currency="EUR" smallMinor />Props
Read from the component's own types, so every prop, every default and every allowed value is listed.
| Prop | Type | Required | Description |
|---|---|---|---|
value | number | Yes | The amount in the currency's minor units (cents, pence; whole yen), as an integer. |
currency | string | Yes | The ISO 4217 code, such as EUR or JPY. |
locale | string | No | |
sign | Sign | No | |
smallMinor | boolean | No | Sets the decimals in a smaller size, for a balance that heads a screen. @default false |
compact | boolean | No | Abbreviates large amounts (€12K), for a chart axis or a tight tile. @default false |
display | "symbol" | "narrowSymbol" | "code" | No | symbol ($), narrowSymbol ($ for every dollar) or code (USD). @default "narrowSymbol" |
Also accepts everything in Omit<TagProps<"data">, "value" | "children">.