Statistic
A statistic is a numeric value display with title, optional prefix, and optional suffix. It groups the components into a single landmark with role="group" and a synthesized aria-label.
Use it for dashboards, KPIs, summary cards, and any place a single prominent number must be paired with a short label.
Example
Show demo markup
<div class="statistic" aria-label="a numeric value display with title, prefix, and suffix">Statistic</div>
Usage example
<script lang="ts">
import Statistic from './Statistic.svelte';
</script>
<Statistic title="Active users" value="1,234" />
<Statistic title="Revenue" value="42">
{#snippet prefix()}$ {/snippet}
{#snippet suffix()} M{/snippet}
</Statistic>
Show Svelte source
// In your Svelte component:
import Statistic from "lily-design-system-svelte-headless/components/Statistic/Statistic.svelte";
<Statistic>
<!-- content -->
</Statistic>
Usage
<Statistic title="Active users" value="12,345" suffix="users" />
<Statistic title="Revenue" value="2,400" prefix="$" suffix="K" />
<Statistic
title="Conversion"
value="4.2"
suffix="%"
label="Conversion rate is 4.2 percent"
/>
Props
title: string (required) -- statistic label/heading
value: string (required) -- pre-formatted value text
prefix: slot (optional) -- element before the value (e.g., currency symbol)
suffix: slot (optional) -- element after the value (e.g., unit or %)
label: string (optional) -- aria-label override
...restProps: any additional HTML attributes
Keyboard Interactions
- None — passive display element.
ARIA
role="group" groups the title and value into a single labeled region
aria-label provides the spoken summary, defaulting to "{title}: {value}"
When to Use
- Use to highlight a single number with a label, especially on dashboards or summary cards.
- Use with prefix or suffix for currency, units, or percentages.
When Not to Use
- Do not use for tabular data — use DataTable.
- Do not use for free-form text content — use BodyText.
- Do not use when the value needs to update with live screen-reader announcements — use a status region.
Headless
Renders semantic group markup with no styling. Consumer formats the value, sizes the type, and chooses any visual emphasis.
Styles
Consumer CSS targets statistic, statistic-title, statistic-value, statistic-prefix, and statistic-suffix. Use larger type and stronger weight for the value than the title.
Testing
- Verify the component renders a
<div> element with class statistic
- Verify
role="group" is set
- Verify
aria-label defaults to "{title}: {value}" when label is not provided
- Verify
aria-label equals the label prop when provided
- Verify the title renders inside
<div class="statistic-title">
- Verify the value renders inside
<div class="statistic-value">
- Verify the prefix renders inside
<span class="statistic-prefix"> only when provided
- Verify the suffix renders inside
<span class="statistic-suffix"> only when provided
Advice
- Designers: Keep titles short and values pre-formatted. Use suffix/prefix for units rather than embedding them in
value.
- Developers: Format numbers in the consumer (locale, separators, decimals) before passing as the
value prop.
Implementation Notes
- Renders a
<div class="statistic" role="group"> container
title is required and renders in <div class="statistic-title">
value is required and renders inside <div class="statistic-value">
- Optional
prefix slot renders in <span class="statistic-prefix">
- Optional
suffix slot renders in <span class="statistic-suffix">
aria-label defaults to "{title}: {value}" and may be overridden via the label prop
- Consumer formats numeric values before passing them as
value
Related components
meter — a gauge displaying a scalar value within a known range
sparkline — a small inline chart showing a data trend
References
- WAI-ARIA Group Role: https://www.w3.org/TR/wai-aria-1.2/#group
- Ant Design Statistic: https://ant.design/components/statistic
Canonical contract
Generated from this component's canonical metadata — the machine-checked source the implementations are held to.
Metadata
- Component: statistic
- PascalCase: Statistic
- Description: a numeric value display with title, prefix, and suffix
- Status: beta — implemented and unit-tested in all seven frameworks with an axe-clean demo page; not yet exercised in composed flows
- HTML tag: <div>
- CSS class: .statistic
- Interactive: no
ARIA
- role="group"
- aria-label is the spoken summary of the statistic
Keyboard
- None — passive display element
Props
title: string (REQUIRED) value: string (REQUIRED) prefix: slot (optional) suffix: slot (optional) label: string (optional) ...restProps: any additional HTML attributes