Skip to content

Currency

An amount of money in its currency, written the person's way: $1,240.00 or 1.240,00 US$. It never assumes a currency: pass the account's.

import { Currency, ValueSkeleton } from '@sypnia/ui/react'

On this page
  1. Lines of an invoice
  2. Skeleton
  3. When to use it
  4. For everyone
  5. Props

Lines of an invoice

LineAmount
Pro plan, November$29.00
Extra events (2.4 million)$12.40
Credit for the outage of Nov 3+$4.50
Same plan billed in pesosCOP 118,900
Revenue this year$1.3M
Code
import { Currency, Table } from '@sypnia/ui/react';

// Always the account's currency, written the person's way. signed marks credits; compact keeps the exact amount on hover.
const lines = [
  { item: 'Pro plan, November', amount: 29, currency: 'USD' },
  { item: 'Extra events (2.4 million)', amount: 12.4, currency: 'USD' },
  { item: 'Credit for the outage of Nov 3', amount: 4.5, currency: 'USD', credit: true },
  { item: 'Same plan billed in pesos', amount: 118_900, currency: 'COP' },
  { item: 'Revenue this year', amount: 1_284_000, currency: 'USD', compact: true },
];
export default function Invoice() {
  return <Table label="Invoice lines" rows={lines} rowKey={(l) => l.item}
    columns={[{ id: 'item', header: 'Line', cell: (l) => l.item }, { id: 'amount', header: 'Amount', numeric: true, cell: (l) => <Currency value={l.amount} currency={l.currency} signed={l.credit} compact={l.compact} /> }]} />;
}

Skeleton

$29.00
Code
import { Currency, ValueSkeleton } from '@sypnia/ui/react';

// An amount and its skeleton.
export default function Skeleton() {
  return (
    <div className="sy-cols sy-cols--stack">
      <span><Currency value={29} currency="USD" /></span>
      <span><ValueSkeleton chars={7} /></span>
    </div>
  );
}

When to use it

Use it when

  • Prices, invoices, balances.
  • signed for credits and refunds.

Do not use it when

  • Amounts without a known currency.

For everyone

  • The currency is written with the amount, never only implied by the page.

Props

CurrencyTypeDefault
currencyrequired string
valuerequired number | null | undefined
compact boolean
signed boolean
ValueSkeletonTypeDefault
chars number 6
  1. Lines of an invoice
  2. Skeleton
  3. When to use it
  4. For everyone
  5. Props

    Search pages, sections and terms