Skip to main content
Kobalte

Statistic

Since v2.0.0@kobalte/core/statisticSource

Displays a labeled numeric value, such as a KPI or dashboard metric.

Import

import { Statistic } from "@kobalte/core/statistic";
// or
import { Root, Label, Value, Description, Trend } from "@kobalte/core/statistic";

Features

  • Auto-wires aria-labelledby/aria-describedby from Statistic.Label/Statistic.Description onto Statistic.Root.
  • Statistic.Value formats its value for the current locale via Intl.NumberFormat, or accepts pre-formatted children directly for units Intl.NumberFormat can't express.
  • Statistic.Value is a polite live region, so value changes (e.g. a real-time metric refreshing) are announced to screen reader users without moving focus.
  • Statistic.Trend generates its own accessible sentence (e.g. "increased by 2.5%") from a signed value — the meaning never depends on an arrow's color or shape alone.

Anatomy

The statistic consists of:

  • Statistic: Contains all the parts of a statistic.
  • Statistic.Label: An accessible label describing the statistic.
  • Statistic.Value: The statistic's value.
  • Statistic.Description: Optional supplementary text (e.g. a breakdown).
  • Statistic.Trend: Indicates the direction and magnitude of change.
<Statistic>
<Statistic.Label />
<Statistic.Value />
<Statistic.Description />
<Statistic.Trend />
</Statistic>

Example

Web traffic
256K
export function BasicExample() {
return (
<Statistic>
<Statistic.Label class={style.label}>Web traffic</Statistic.Label>
<Statistic.Value
class={style.value}
value={255650}
formatOptions={{ notation: "compact" }}
/>
</Statistic>
);
}
.label {
display: block;
font-size: 12px;
color: hsl(240 4% 46%);
margin-bottom: 2px;
}
.value {
display: block;
font-size: 28px;
font-weight: 600;
color: hsl(240 6% 20%);
}
.description {
display: block;
font-size: 12px;
color: hsl(240 4% 60%);
margin-top: 2px;
}
.trend--increase,
.trend--decrease {
margin-left: 8px;
display: inline-flex;
align-items: center;
gap: 2px;
font-size: 13px;
font-weight: 500;
}
.trend--increase {
color: hsl(142 71% 35%);
}
.trend--decrease {
color: hsl(0 72% 51%);
}
.row {
display: flex;
align-items: flex-start;
gap: 16px;
}
.button {
border-radius: 6px;
border: 1px solid hsl(240 5% 84%);
background-color: white;
padding: 6px 12px;
font-size: 13px;
color: hsl(240 6% 20%);
cursor: pointer;
}
.button:hover {
background-color: hsl(240 5% 96%);
}
[data-kb-theme="dark"] .value {
color: hsl(240 5% 96%);
}
[data-kb-theme="dark"] .button {
background-color: hsl(240 6% 10%);
border-color: hsl(240 5% 20%);
color: hsl(240 5% 96%);
}

Usage

With description

Statistic.Description adds supplementary text (e.g. a breakdown), wired to Statistic.Root via aria-describedby.

Security insights
40
12 high, 28 low
import { Statistic } from "@kobalte/core/statistic";
function App() {
return (
<Statistic>
<Statistic.Label class="label">Security insights</Statistic.Label>
<Statistic.Value class="value" value={40} />
<Statistic.Description class="description">12 high, 28 low</Statistic.Description>
</Statistic>
);
}

With trend

Statistic.Trend renders whatever visual you pass as children (an arrow glyph, an icon, colored text — Kobalte has no opinion), marks it aria-hidden, and separately generates its own accessible sentence from the signed value prop.

Cache rate
16.2%
decreased by 2.5%
import { Statistic } from "@kobalte/core/statistic";
import "./style.css";
function App() {
return (
<Statistic>
<Statistic.Label class="label">Cache rate</Statistic.Label>
<Statistic.Value
class="value"
value={0.162}
formatOptions={{ style: "percent", maximumFractionDigits: 1 }}
/>
<Statistic.Trend
value={-0.025}
formatOptions={{ style: "percent", maximumFractionDigits: 1 }}
class="trend--decrease"
>
▼ 2.5%
</Statistic.Trend>
</Statistic>
);
}
.trend--decrease {
margin-left: 8px;
color: hsl(0 72% 51%);
font-weight: 500;
}

Live updating value

Statistic.Value renders aria-live="polite" aria-atomic="true" — when value changes, screen readers announce the new value without moving focus, which matters for dashboards where metrics refresh in the background.

Workers invocations
805

API Reference

Statistic

Statistic is equivalent to the Root import from @kobalte/core/statistic.

PropDescription
idstring
A unique identifier for the component. The id is used to generate id attributes for nested components. If no id prop is provided, a generated id will be used.

Statistic.Value

PropDescription
valuenumber
The numeric value to display, formatted for the current locale.
formatOptionsIntl.NumberFormatOptions
Options for formatting value. Defaults to {}.
childrenJSX.Element
Pass a pre-formatted value directly instead — takes precedence over value/formatOptions.

Statistic.Value's id is wired to Statistic's aria-labelledby when used in place of Statistic.Label.

Statistic.Trend

PropDescription
valuenumber
The signed change represented by the trend, e.g. 0.025 for a 2.5% increase or -0.025 for a 2.5% decrease. Drives data-direction and the accessible text.
formatOptionsIntl.NumberFormatOptions
Options for formatting the absolute value of value. Defaults to { style: "percent" }.
translationsStatisticIntlTranslations
Localization strings.
childrenJSX.Element
The visual representation of the trend (e.g. an arrow + formatted value). Rendered with aria-hidden="true".
Data attributeDescription
data-direction='increase'Present when value is positive.
data-direction='decrease'Present when value is negative.
data-direction='noChange'Present when value is 0.

Rendered elements

ComponentDefault rendered element
Statisticdiv
Statistic.Labelspan
Statistic.Valuediv
Statistic.Descriptionspan
Statistic.Trenddiv

Last updated: 11/28/26, 9:28 PM