Skip to content
العربية
Saudi and bilingual kit

Money, formatMoney

Amounts: the Riyal sign left of the number with a space, Western digits, in both directions. Never “SAR”. maxDecimals keeps up to 6 decimals for unit prices; accounting puts negative amounts in brackets. Zero never shows a minus sign, and a broken amount shows “—”.

import { Money, formatMoney } from "@percentsa/ui";

Examples

1,25099.50

formatMoney(1250, { decimals: 2 }) = 1,250.00

Code
export function MoneyExample() {
  return (
    <Stack gap={3}>
      <Money amount={1250} className="text-3xl font-semibold" />
      <Money amount={99.5} />
      <Text size="sm" tone="subtle" dir="ltr">formatMoney(1250, {"{ decimals: 2 }"}) = {formatMoney(1250, { decimals: 2 })}</Text>
    </Stack>
  );
}
314.7826(1,234.50)

formatMoney(-0.004, { decimals: 2 }) = 0.00

Code
export function MoneyOptionsExample() {
  return (
    <Stack gap={2}>
      <Money amount={314.7826} maxDecimals={6} />
      <Money amount={-1234.5} decimals={2} accounting />
      <Text size="sm" tone="subtle" dir="ltr">formatMoney(-0.004, {"{ decimals: 2 }"}) = {formatMoney(-0.004, { decimals: 2 })}</Text>
    </Stack>
  );
}