Skip to main content

Stat

Info:Metrics
20

A single metric: a prominent value with its label, optional trend delta, and caption.

metric kpi number figure trend delta big number

Live demo

live · @xtyle/astro

Stat

A dashboard strip

$48,250Monthly revenue+12.5%vs. last month
1,204Active themes+8this week
17Churned-3vs. last month
57 / 57Token coverage0held steady

Trends carry direction, not just color

920Up+24.1%
312Down-6.4%
488Flat0.0%

Direction and sentiment are separate axes

trend sets the arrow; sentiment sets the color and defaults to the trend's reading. So up can be bad, down can be good, and a direction can carry no judgment at all.

4.8%Error rate+2.1%up is bad
142msp95 latency-18msdown is good
312Runs-8%24h · neutral
1,020Queue depth+140

Three sizes, two alignments

3.2kSmall
3.2kMedium
3.2kLarge

align="center"

8,402Sessions+11%
4m 18sAvg. timeper session
31%Bounce-2%

Stat presents one figure at a glance: a large value (the default slot) under a small uppercase label, with an optional delta carrying a trend (up / down / flat) and an optional caption for context. The value and delta render in tabular figures so columns of stats align digit-for-digit.

trend picks the delta's directional arrow; a separate sentiment (positive / negative / neutral) picks its color and defaults to the trend's own reading (up→positive/green, down→negative/red, flat→neutral). Splitting the axes lets an up-is-bad metric (a rising error rate) paint red on an up-arrow, or a sentiment-neutral metric show a direction in a muted tint, while the color is always paired with the arrow so meaning never rides on color alone. Pure presentation: compose several in a Grid or Cluster for a dashboard strip, or drop one into a Card header.

When to use

How this component composes with the rest of the set.

Lay several in a Grid or Cluster for a dashboard strip; the tabular figures keep the values aligned.
Drop one into a Card to head a panel with its key number.
Pair the delta + trend with period-over-period figures; the arrow carries direction without relying on color.
For a metric where up is bad (error rate, latency, queue depth) set trend="up" sentiment="negative"; for a direction that carries no good/bad meaning set sentiment="neutral" to keep the arrow but drop the green/red.

Props

8 props, straight from the manifest.

PropTypeDefaultBindingsDescription
label string
html svelte astro
The metric name rendered above the value.
delta string
html svelte astro
An optional change indicator (e.g. `+12.5%`) rendered below the value with a trend arrow.
trend StatTrend
up down flat
flat
html svelte astro
Picks the delta's directional arrow (▲ up, ▼ down, a flat bar). Also the default color, via `sentiment`.
sentiment StatSentiment
positive negative neutral
html svelte astro
Colors the delta independently of its arrow: positive (`--success-vivid`), negative (`--danger-vivid`), neutral (`--neutral-vivid`). Omit to derive from `trend` (up→positive, down→negative, flat→neutral), so an up-is-bad metric sets `trend="up" sentiment="negative"` and a directional-but-neutral one sets `sentiment="neutral"`.
caption string
html svelte astro
An optional subtle line of context below the value.
size Size
sm md lg
md
html svelte astro
Scales the value (`sm` → `xl`, `md` → `2xl`, `lg` → `3xl`).
align StatAlign
start center
start
html svelte astro
Block alignment of the stat's contents.
inline boolean false
html svelte astro
Lays the stat out horizontally (label, value, and trend delta on one baseline, like a ticker) for a status strip or a dense row instead of a dashboard tile.

Appearance

Sizes

sm

.xtyle-stat--sm

Compact value.

md

default
.xtyle-stat

Default.

lg

.xtyle-stat--lg

Large display value.

Anatomy

The named parts that make up the component, with their selectors.

stat

.xtyle-stat

The flex-column root carrying the alignment and size classes.

--font-sans --space-1

label

.xtyle-stat__label

The metric name: small, uppercase, and muted, rendered above the value via flex order.

--text-xs --weight-semibold --leading-normal --fg-2

value

.xtyle-stat__value

The headline figure: display font, bold, tabular, in the primary ink.

--font-display --text-xl --text-2xl --text-3xl --weight-bold --leading-tight --fg-0

delta

.xtyle-stat__delta

The optional change indicator: a directional arrow (from trend) over a base --neutral-text, tinted by sentiment (positive --success-vivid, negative --danger-vivid, neutral --neutral-vivid).

--text-sm --weight-semibold --space-1 --neutral-text --neutral-vivid --success-vivid --danger-vivid

caption

.xtyle-stat__caption

An optional subtle line of context below the value.

--text-xs --leading-normal --fg-3

Tokens & coverage

What the component consumes, checked live against what the algorithm produces.

Success:fully covered 20/20 consumed tokens produced default register: 299 tokens

Live coverage check against the xtyle-default register (derive(xtyleDefault, { anchors })coverComponent(manifest, register)). Every token this component consumes must be a key the algorithm produces.

--danger-vivid --fg-0 --fg-2 --fg-3 --font-display --font-sans --leading-normal --leading-tight --neutral-text --neutral-vivid --space-1 --space-2 --success-vivid --text-2xl --text-3xl --text-sm --text-xl --text-xs --weight-bold --weight-semibold

Slots

default
html svelte astro

The metric value.

Accessibility

The trend pairs its color with a directional arrow (▲ up, ▼ down, a flat bar for no change), so the change reads without color perception (WCAG 1.4.1).
The arrow glyph is a decorative aria-hidden SVG; the delta's meaning comes from its text.
Order is visual only; the label sits above the value via flex order, while the DOM keeps value-then-label, so a screen reader reads the figure first.

Code

Metrics, trends, and sizes

A value under its label, with optional trend deltas and captions, across the three sizes and both alignments, plus the inline ticker layout that lays label, value, and delta on one line.

<xtyle-stat label="Monthly revenue" delta="+12.5%" trend="up" caption="vs. last month">$48,250</xtyle-stat>

<xtyle-stat label="Active themes" delta="-3" trend="down">1,204</xtyle-stat>

<xtyle-stat label="Token coverage" size="lg" align="center">57 / 57</xtyle-stat>

<xtyle-stat label="components" delta="+1" trend="up" inline>49</xtyle-stat>
<script lang="ts">
	import { Stat } from "@xtyle/svelte";
</script>

<Stat label="Monthly revenue" delta="+12.5%" trend="up" caption="vs. last month">$48,250</Stat>

<Stat label="Active themes" delta="-3" trend="down">1,204</Stat>

<Stat label="Token coverage" size="lg" align="center">57 / 57</Stat>

<Stat label="components" delta="+1" trend="up" inline>49</Stat>
---
import { Stat } from "@xtyle/astro";
---

<Stat label="Monthly revenue" delta="+12.5%" trend="up" caption="vs. last month">$48,250</Stat>

<Stat label="Active themes" delta="-3" trend="down">1,204</Stat>

<Stat label="Token coverage" size="lg" align="center">57 / 57</Stat>

<Stat label="components" delta="+1" trend="up" inline>49</Stat>

Direction vs. sentiment

sentiment colors the delta independently of the trend arrow: an up-is-bad error rate arrows up but reads red, a falling latency arrows down but reads green, and a neutral run-count keeps the arrow without a good/bad tint.

<!-- Up is bad: a rising error rate arrows up but paints red. -->
<xtyle-stat label="Error rate" delta="+2.1%" trend="up" sentiment="negative" caption="last hour">4.8%</xtyle-stat>

<!-- Down is good: latency falling arrows down and paints green. -->
<xtyle-stat label="p95 latency" delta="-18ms" trend="down" sentiment="positive">142ms</xtyle-stat>

<!-- Directional but neutral: a run-count delta shows the arrow in a muted tint, no good/bad. -->
<xtyle-stat label="Runs" delta="-8%" trend="down" sentiment="neutral" caption="24h">312</xtyle-stat>