Skip to content

Format Number ​

Formats

Loading...

Formats a number using the specified locale and options. Localization is handled by the browser's Intl.NumberFormat API — no language packs required.

  • Tag: <flint-format-number>
  • Class: FlintFormatNumber

Import ​

ts
import '@getufy/flint-ui'; // auto-registers all
// or
import { FlintFormatNumber } from '@getufy/flint-ui';

Usage ​

html
<flint-format-number></flint-format-number>

Properties ​

PropertyAttributeTypeDefaultDescription
valuevaluenumber0The number to format.
typetype'currency' | 'decimal' | 'percent' | 'unit''decimal'The formatting style to use.
noGroupingno-groupingbooleanfalseTurns off grouping separators (e.g. thousands separator).
currencycurrencystring'USD'The ISO 4217 currency code to use when formatting (e.g. 'USD', 'EUR', 'GBP').
currencyDisplaycurrency-display'symbol' | 'narrowSymbol' | 'code' | 'name''symbol'How to display the currency.
notationnotation'standard' | 'scientific' | 'engineering' | 'compact''standard'Number notation style. 'compact' renders e.g. "1.2K" or "3.4M".
compactDisplaycompact-display'short' | 'long''short'How to display compact notation — 'short' (1K) or 'long' (1 thousand).
signDisplaysign-display'auto' | 'never' | 'always' | 'exceptZero''auto'When to show the sign.
unitunitstring''ECMA-402 unit identifier (e.g. 'kilometer', 'kilogram', 'celsius'). Required when type='unit'.
unitDisplayunit-display'short' | 'long' | 'narrow''short'How to display the unit when type='unit'.
minimumIntegerDigitsminimum-integer-digitsnumber | undefinedundefinedThe minimum number of integer digits (1–21).
minimumFractionDigitsminimum-fraction-digitsnumber | undefinedundefinedThe minimum number of fraction digits (0–20).
maximumFractionDigitsmaximum-fraction-digitsnumber | undefinedundefinedThe maximum number of fraction digits (0–20).
minimumSignificantDigitsminimum-significant-digitsnumber | undefinedundefinedThe minimum number of significant digits (1–21).
maximumSignificantDigitsmaximum-significant-digitsnumber | undefinedundefinedThe maximum number of significant digits (1–21).
langlangstring''BCP 47 language tag for formatting locale. Inherits from the document when unset.

CSS Parts ​

NameDescription
baseThe component's base wrapper element.

CSS Custom Properties ​

PropertyDefault
--flint-format-number-color—
--flint-format-number-font-size—
--flint-format-number-font-weight—
--flint-format-number-font-family—
--flint-format-number-positive-color—
--flint-format-number-negative-color—