Number Format
Displays a number, price or percentage formatted for a locale by the browser's Intl.NumberFormat.
<arc-number-format>Overview
Number Format renders a number formatted by the browser's Intl.NumberFormat. Pass a raw value and a type (number, currency, percent or compact), and it adds thousands separators, currency symbols, percent signs or compact suffixes like "12.3K" and "1.2M".
It sets font-variant-numeric: tabular-nums and the monospace font, so numbers line up in tables, stat grids and dashboards. The locale prop takes a BCP 47 tag, and Intl.NumberFormat applies that locale's conventions: with de-DE, 1234.5 shows as "1.234,5". Without it, the locale is en-US.
For the percent type, pass the percentage itself: 50 displays "50%". Plain Intl.NumberFormat multiplies by 100, so it would want 0.5.
Guidelines
Do
- Use it in tables and stat cards where numbers need to line up
- Set `type="currency"` and a `currency` code for money
- Use `notation="compact"` for large numbers in tight layouts
- Set `locale` in multi-language apps
Don't
- Don't use it for animated counting. Use Animated Number
- Don't add your own monospace styling. It already sets the mono font and tabular-nums
- Don't leave out `currency` with `type="currency"` unless you mean USD
Features
- `decimals` sets decimal places, 0 to 20. Unset, it's 0 for numbers, 2 for currency and 1 for percent
- `currency` takes an ISO 4217 code and defaults to USD
- Inherits size and color from its parent
Preview
Usage
<!-- Basic number with thousands separators -->
<arc-number-format value="1234567"></arc-number-format>
<!-- Currency -->
<arc-number-format value="1234.50" type="currency" currency="USD"></arc-number-format>
<!-- Percentage (50 = 50%) -->
<arc-number-format value="99.9" type="percent"></arc-number-format>
<!-- Compact notation -->
<arc-number-format value="1234567" notation="compact"></arc-number-format>
<!-- European locale -->
<arc-number-format value="1234.56" type="currency" currency="EUR" locale="de-DE"></arc-number-format>import { NumberFormat } from '@arclux/arc-ui-react';
function PricingTable({ price, change, users }) {
return (
<div>
<NumberFormat value={price} type="currency" />
<NumberFormat value={change} type="percent" />
<NumberFormat value={users} notation="compact" />
</div>
);
}<script setup>
import { NumberFormat } from '@arclux/arc-ui-vue';
const price = 1234.50;
const change = 12.5;
</script>
<template>
<NumberFormat :value="price" type="currency" />
<NumberFormat :value="change" type="percent" />
</template><script>
import { NumberFormat } from '@arclux/arc-ui-svelte';
let price = 1234.50;
let change = 12.5;
</script>
<NumberFormat value={price} type="currency" />
<NumberFormat value={change} type="percent" />import { Component } from '@angular/core';
import { NumberFormat } from '@arclux/arc-ui-angular';
@Component({
imports: [NumberFormat],
template: `
<arc-number-format [value]="price" type="currency" />
<arc-number-format [value]="change" type="percent" />
`,
})
export class MetricsComponent {
price = 1234.50;
change = 12.5;
}import { NumberFormat } from '@arclux/arc-ui-solid';
function Metrics() {
return (
<div>
<NumberFormat value={1234.50} type="currency" />
<NumberFormat value={12.5} type="percent" />
</div>
);
}import { NumberFormat } from '@arclux/arc-ui-preact';
function Metrics() {
return (
<div>
<NumberFormat value={1234.50} type="currency" />
<NumberFormat value={12.5} type="percent" />
</div>
);
}API
localestring'en-US'- BCP 47 locale tag for locale-aware formatting
currencystring'USD'- ISO 4217 currency code, used when type is "currency"
valuenumber0- The number to format
type'number' | 'currency' | 'percent' | 'compact''number'- Formatting style to apply
decimalsnumber0- Number of decimal places, 0 to 20 (
Intl.NumberFormat's own range). Unset uses a per-format default: 0 for number, 2 for currency, 1 for percent. notation'standard' | 'compact''standard'- Number notation: compact gives "12.3K", "1.2M"