SearchCtrlK

  • ↑↓navigate
  • ↵open
  • escclose

Can’t find it? Contact us

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
tsx
<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.

Terminal
npm add @sdxc/ui remix
typescript
import "@sdxc/ui/theme.css";

Or copy it into your project to edit it:

Terminal
sdxc ui add amount

Usage

typescript
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

tsx
<Amount value={4500} currency="GBP" sign="ledger" />
tsx
<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.

PropTypeRequiredDescription
valuenumberYesThe amount in the currency's minor units (cents, pence; whole yen), as an integer.
currencystringYesThe ISO 4217 code, such as EUR or JPY.
localestringNo
signSignNo
smallMinorbooleanNoSets the decimals in a smaller size, for a balance that heads a screen. @default false
compactbooleanNoAbbreviates large amounts (€12K), for a chart axis or a tight tile. @default false
display"symbol" | "narrowSymbol" | "code"Nosymbol ($), narrowSymbol ($ for every dollar) or code (USD). @default "narrowSymbol"

Also accepts everything in Omit<TagProps<"data">, "value" | "children">.

@sdxc/ui

Can’t find it? Contact us