Skip to content
Nana UI

Format Number

View .md Download

Formats a number with Intl.NumberFormat — decimal, currency or percent, with optional compact notation (1K / 1M) and fixed precision.

Terminal window
npm install @nana-tec/ui-components
import "@nana-tec/ui-components/format-number";
<nana-format-number type="currency" value="1234.5" currency="USD"></nana-format-number>

Properties

PropertyAttributeTypeDefaultDescription
currencystring'USD'ISO 4217 currency code (when `type="currency"`)
currencyDisplaycurrency-display'symbol' | 'narrowSymbol' | 'code' | 'name''symbol'How to display the currency
groupingbooleantrueGroup thousands (off → no separators)
localestring | undefinedBCP 47 locale (defaults to the document locale)
maximumFractionDigitsmaximum-fraction-digitsnumber | undefinedMaximum fraction digits
minimumFractionDigitsminimum-fraction-digitsnumber | undefinedMinimum fraction digits
notation'standard' | 'compact''standard'`standard` or `compact` (1K, 1M)
typeFormatNumberType'decimal'Formatting style
valuenumber0The number to format
Explore Format Number interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook