Codeways UI
Browse components

Data display

Money / MoneyTotals

A decimal string in, a tabular amount out - never summed across currencies.

@codeways/ui/money

Amounts

A decimal string in, a right-aligned tabular amount out - the ISO code is a muted prefix, never a symbol.

AUD1,850.00USD4,200.00LKR612,500.00−USD350.00AUD0.00–

States

Negative uses U+2212, never a hyphen or parentheses; zero is de-emphasised; a missing value renders an en dash.

positiveLKR1,234,567.50
negative−USD72.30
zeroAUD0.00
missing–

MoneyTotals

Never summed across currencies - group with sumMoneyByCurrency first, then render one total row per currency.

Five invoice lines in AUD, USD and LKR - three totals, never one converted figure.
Total AUD
AUD2,830.00
Total USD
USD3,850.00
Total LKR
LKR612,500.00

Usage

import { Money, MoneyTotals, formatMoney, sumMoneyByCurrency } from "@codeways/ui/money";

// A single amount.
<Money amount={invoice.total} currency={invoice.currency} />

// Never sum across currencies - group first, one total per currency.
<MoneyTotals totals={sumMoneyByCurrency(lines.map((l) => ({ currency: l.currency, amount: l.amount })))} />

// Plain text, e.g. an email body.
formatMoney(invoice.total, invoice.currency); // "AUD 1,850.00"