Skip to content
BigBang

Popular

    ↑↓Navigate↵OpenEscClose
    TR

    Components

    MoneyText

    An amount of money written exactly from minor units, in the Provider language.

    Storybook
    Storybook
    Source
    Source

    Wherever an amount of money is shown: a table cell, a summary card, a confirmation screen.

    • To enter an amount: Use AmountInput.
    • For numbers that are not money: Intl.NumberFormat or StatCard is enough for counts and percentages.

    The amount always travels in the smallest unit (cents) as a bigint or an integer string: 123456n means 1.234,56 ₺. A floating-point number is never accepted, so there is no rounding error. The number of fraction digits comes from the currency: 2 for TRY, 0 for JPY.

    ₺1,234.56₺1,234.56TRY 1,234.56€1,234.56
    import { MoneyText, Provider } from '@bigbang/ui';
    export default function Default() {
    return (
    <Provider locale="en-GB">
    <div className="flex flex-col items-start gap-md">
    <MoneyText amount={123456n} size="lg" />
    <MoneyText amount="123456" />
    <MoneyText amount={123456n} display="code" />
    <MoneyText amount={123456n} currency="EUR" />
    </div>
    </Provider>
    );
    }
    1. Sign: Minus always; plus only with tone="sign" or signDisplay.
    2. Integer part: Grouped by language (a point in Turkish).
    3. Fraction: The decimal separator and the minor units; smaller with fraction="subtle".
    4. Currency: At the end in Turkish, by the locale pattern in English.
    • The format comes from Intl.NumberFormat fed the exact decimal string of the amount; even 20-digit amounts do not drift.
    • When the amount changes, the new value rises in from below.
    • The root is <data value="1234.56">, so the machine-readable value is in the page too.
    • hidden replaces the amount with “••••” and the currency; the amount is then nowhere in the page (text, title, aria-*, data-*, the <data> value) and screen readers hear “Amount hidden”. The show and hide toggle is app state.
    • compact writes short notation (“€1.2m”); only for charts and summaries, never for an amount the user acts on.
    • Align amounts to the end in tables; tabular-nums keeps digits the same width.
    • Do not change the currency position within a screen; use the default.
    • Do not rely on colour alone; tone="sign" writes the sign too.
    Key TR EN
    ui.money.currency-position end locale
    ui.money-text.hidden Tutar gizli Amount hidden