Installation
Section titled “Installation”- Package
@bigbang/ui- Import
import { MoneyText } from '@bigbang/ui';- Source
- MoneyText.tsx
- Storybook
- MoneyText · Playground
MoneyText is in the @bigbang/ui package.
import { MoneyText } from '@bigbang/ui';
<MoneyText amount={123456n} />; // ₺1,234.56 in EnglishOutside components, formatMoney(amount, { locale, currency }) gives the same format and minorToDecimal(minor, digits) the exact decimal string.
amountRequired- Description
- The amount in minor units (kuruş, cents) as a bigint or an integer string:
123456nis 1.234,56. Never a float. - Type
MinorUnits
currency- Description
- ISO 4217 currency code; its fraction digits come from Intl (2 for TRY, 0 for JPY).
- Type
string- Default
'TRY'
display- Description
- How the currency is written:
narrowSymbol(₺),symbol,code(TRY),nameornone. - Type
'symbol' | 'narrowSymbol' | 'code' | 'name' | 'none'- Default
'narrowSymbol'
currencyPosition- Description
- Where the currency goes. Without it,
ui.money.currency-position: after the number in Turkish ("1.234,56 ₺"), the locale pattern in English. - Type
'locale' | 'start' | 'end'
signDisplay- Description
- When the sign shows.
tone="sign"switches it toexceptZero, so a credit reads "+". - Type
'negative' | 'auto' | 'always' | 'exceptZero' | 'never'- Default
'auto'
tone- Description
signcolours positive amounts success and negative ones danger; the sign is always written too.- Type
'default' | 'subtle' | 'sign'- Default
'default'
size- Description
- Text size: body small and medium, heading small and extra large.
- Type
'sm' | 'md' | 'lg' | 'xl'- Default
'md'
fraction- Description
subtlesets the decimal separator and fraction smaller and lighter.- Type
'default' | 'subtle'- Default
'default'
compact- Description
- Short compact notation, such as "1,2 Mn ₺", for charts and summaries. Never for an amount the user acts on.
- Type
boolean- Default
false
className- Description
- Added to the root element; use it for layout only.
- Type
string
Data attributes
Section titled “Data attributes”data-component="money-text"anddata-sign:positive,negative,zero.data-part="fraction": the decimal separator and the minor units.