Skip to content
Nana UI

Formatters

Format Number

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

View .md Download
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
currencycurrencystring'USD'ISO 4217 currency code (when type="currency")
currencyDisplaycurrency-display'symbol' | 'narrowSymbol' | 'code' | 'name''symbol'How to display the currency
groupinggroupingbooleantrueGroup thousands (off → no separators)
localelocalestring | undefined—BCP 47 locale (defaults to the document locale)
maximumFractionDigitsmaximum-fraction-digitsnumber | undefined—Maximum fraction digits
minimumFractionDigitsminimum-fraction-digitsnumber | undefined—Minimum fraction digits
notationnotation'standard' | 'compact''standard'standard or compact (1K, 1M)
typetypeFormatNumberType'decimal'Formatting style
valuevaluenumber0The number to format
Explore Format Number interactively Every state, prop, and edge case — with live controls — in Storybook.
View in Storybook