Number Value
A locale-aware number formatter — the four Intl.NumberFormat styles, compact notation, sign control and optional affixes, rendered as tabular figures.
Usage
NumberValue is a formatting primitive. It takes one value and renders the string
Intl.NumberFormat would produce for it, via @internationalized/number, in a span that carries
tabular-nums. The convenience props — style, currency, notation, signDisplay and the
fraction-digit pair — are the options you reach for most; formatOptions opens the rest.
It does not animate. Rolling digits belong to headline display values, where the movement is the point; here it would fight the component's job and break the column alignment that tabular figures exist to give you.
Anatomy
Import the NumberValue component and access all parts using dot notation.
import {NumberValue} from "@blakeui/pro-react";
<NumberValue value={0}>
<NumberValue.Prefix />
<NumberValue.Suffix />
</NumberValue>;Both parts are optional and the root renders the formatted value on its own. Order in the markup does not matter — the root picks the prefix and the suffix out of its children and always places them either side of the value.
Compact
Currency
The currency code chooses the symbol and the number of decimals. Yen has no minor unit, so JPY
rounds to whole yen while the other three pad to two places.
Format Options
formatOptions takes the full Intl.NumberFormatOptions surface plus numberingSystem. It
replaces the convenience props rather than merging with them, so anything you still want —
style, currency, notation — has to be named inside the object.
Percent
Sign Display
never drops the sign rather than the magnitude, so −42 renders as 42. Use it only where the
direction is already carried by something else, such as a colour or an adjacent arrow.
Tabular Nums
Every root gets font-variant-numeric: tabular-nums from .number-value, so digits occupy equal
width and a stacked column lines up on the decimal point. A render-function child is the one way out
of it: that form renders your element instead of the root, so add number-value to your own
className if the value still needs to align.
With Prefix Suffix
CSS Classes
Base Class
.number-value— The root span. Its only declaration isfont-variant-numeric: tabular-nums. There is no fill, no stroke, no type scale and no colour: the value inherits its typography from whatever it sits in, which is what lets the same component read as a 12px table cell and a 32px headline without a size prop.
Element Classes
None of the three carries a declaration. They are structural hooks — stable targets for your own stylesheet, and the reason each part is a separate element rather than a text node.
.number-value__value— The formatted number. Always present, always the middle child..number-value__prefix— Text before the value. Rendered only when aNumberValue.Prefixis passed..number-value__suffix— Text after the value. Rendered only when aNumberValue.Suffixis passed.
Data Attributes
[data-slot="number-value"],[data-slot="number-value-value"],[data-slot="number-value-prefix"],[data-slot="number-value-suffix"]— One per part, so any of them can be targeted without depending on its BEM class.
Both sets of hooks are absent under a render-function child, which returns your element in place of the whole tree.
API Reference
NumberValue
The root. Formats value for the resolved locale and renders it in a span.
| Prop | Type | Default | Description |
|---|---|---|---|
value | number | — | Required. The number to format. It is a raw quantity, not a pre-formatted string — under style="percent" it is the ratio, so 0.1432 renders as 14%. |
style | "decimal" | "currency" | "percent" | "unit" | "decimal" | Which formatting style to use. currency requires currency and unit requires unit; omitting the companion prop throws from Intl rather than falling back. This prop shadows the native style attribute, which the root does not accept — style the element through className. |
currency | string | — | ISO 4217 code, e.g. "USD". It sets the symbol and the number of decimals — "JPY" has no minor unit and so rounds to whole yen. |
unit | string | — | A sanctioned unit identifier, e.g. "celsius", "gigabyte", or a rate such as "megabyte-per-second". Arbitrary strings are not accepted. |
notation | "standard" | "compact" | "scientific" | "engineering" | "standard" | How the magnitude is written. compact abbreviates using the locale's own scale words; engineering differs from scientific only in snapping the exponent to a multiple of three. |
signDisplay | "auto" | "always" | "exceptZero" | "never" | "auto" | When to print the sign. exceptZero is the one for deltas; never discards the sign, not the magnitude. |
minimumFractionDigits | number | — | Fewest fraction digits to print, padding with zeros. |
maximumFractionDigits | number | — | Most fraction digits to print, rounding beyond that. Worth setting under style="percent", whose default of 0 turns a small rate into 1%. |
locale | string | — | A BCP 47 tag that overrides the locale from the nearest I18nProvider. Left out, the value follows the app's locale — which is normally what you want, and this prop is for the exceptions, such as a figure that must stay in its source locale. |
formatOptions | NumberFormatOptions | — | Options passed straight through to the formatter: the whole Intl.NumberFormatOptions surface plus numberingSystem. It replaces every convenience prop above rather than merging with them, so re-state anything you still need inside the object. |
children | ReactNode | ((formatted: string) => ReactNode) | — | Either NumberValue.Prefix / NumberValue.Suffix parts, or a function receiving the formatted string. The function form renders your element in place of the root, so the class, the data attributes and the tabular figures are yours to reapply. |
className | string | — | Merged onto .number-value. Ignored under a render-function child, which renders no root. |
Also accepts every native span attribute except children and style.
NumberValue.Prefix
Text before the value. A span, rendered inside the root ahead of .number-value__value.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Required. The affix — a currency code, a comparison operator, a short label. It is content rather than decoration, so it is read out with the number. |
className | string | — | Merged onto .number-value__prefix. The part carries no styling of its own, so this is where its size, weight, colour and the gap to the value come from. |
Also accepts every native span attribute.
NumberValue.Suffix
Text after the value. A span, rendered inside the root behind .number-value__value.
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | — | Required. The affix — a denominator, a unit, a per-period qualifier. Prefer a real unit style where one exists, and keep this for the cases Intl has no identifier for. |
className | string | — | Merged onto .number-value__suffix. As with the prefix, all of its typography comes from here. |
Also accepts every native span attribute.
List View
A single-column interactive list with keyboard navigation, selection, and accessible item actions, built on RAC GridList.
Timeline
A composable timeline — a real ordered list with a marker rail, six semantic statuses, and event content you compose yourself from cards, chips, avatars, and semantic HTML.