Stat
Key figures with label, value, and help text in three value sizes.
123456789101112131415import { Stat } from "#components/ui/ui-sdk/stat.tsx";
export function Example() { return ( // size resolves once on Root; parts inherit it via context and Root // exposes a data-size attribute <Stat.Root size="md"> <Stat.Label>Installs per day</Stat.Label> <Stat.ValueText> 10,482 <Stat.ValueUnit>pkg</Stat.ValueUnit> </Stat.ValueText> <Stat.HelpText>+12% this month</Stat.HelpText> </Stat.Root> );}Sizes
Install
1npx stylexblocks add statSource
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124import * as stylex from "@stylexjs/stylex";import { createSlotRecipeContext } from "#lib/ui-sdk/create-slot-recipe-context.tsx";import { defineSlotRecipe } from "#lib/recipe-props.ts";import { statIndicatorSvgVars } from '@stylexblocks/ui/slot-recipes/stat.stylex.ts'
import { fontSizes } from '@stylexblocks/ui/tokens/font-sizes.stylex.ts'import { fontWeights } from '@stylexblocks/ui/tokens/font-weights.stylex.ts'import { letterSpacings } from '@stylexblocks/ui/tokens/letter-spacings.stylex.ts'import { lineHeights } from '@stylexblocks/ui/tokens/line-heights.stylex.ts'import { semanticColors } from '@stylexblocks/ui/semantic-tokens/colors.stylex.ts'import { spacing } from '@stylexblocks/ui/tokens/spacing.stylex.ts'
const statRoot = stylex.create({ base: { display: 'flex', flexDirection: 'column', gap: 0, position: 'relative', flex: 1, },})
const statLabel = stylex.create({ base: { color: semanticColors.fgMuted, fontSize: fontSizes.sm, lineHeight: lineHeights.sm, },})
const statHelpText = stylex.create({ base: { color: semanticColors.fgMuted, fontSize: fontSizes.xs, lineHeight: lineHeights.xs, },})
const statValueUnit = stylex.create({ base: { color: semanticColors.fgMuted, fontSize: fontSizes.xs, lineHeight: lineHeights.xs, fontWeight: 'initial', letterSpacing: 'initial', },})
const statValueText = stylex.create({ base: { verticalAlign: 'baseline', fontWeight: fontWeights.semibold, letterSpacing: letterSpacings.tight, fontFeatureSettings: 'pnum', fontVariantNumeric: 'proportional-nums', display: 'inline-flex', gap: spacing._1, },})
const statValueTextSizes = stylex.create({ sm: { fontSize: fontSizes.xl, lineHeight: lineHeights.xl, }, md: { fontSize: fontSizes._2xl, lineHeight: lineHeights._2xl, }, lg: {},})
const statIndicator = stylex.create({ base: { display: 'inline-flex', alignItems: 'center', justifyContent: 'center', marginEnd: 1, [statIndicatorSvgVars.width]: '1em', [statIndicatorSvgVars.height]: '1em', },})
const statIndicatorSvg = stylex.create({ base: { width: statIndicatorSvgVars.width, height: statIndicatorSvgVars.height, },})
export type StatSize = keyof typeof statValueTextSizes
// defineSlotRecipe validates the shape at compile time: default values must// exist in the axis maps, and slot keys must be `styles` or a declared axisconst statSlotRecipe = defineSlotRecipe({ slots: { root: { styles: statRoot }, label: { styles: statLabel }, valueText: { styles: statValueText, sizes: statValueTextSizes }, valueUnit: { styles: statValueUnit }, helpText: { styles: statHelpText }, indicator: { styles: statIndicator }, }, defaultVariants: { size: "md" },});
/** * Stat — recipe and component colocated in one file. `<Stat.Root size>` * resolves the recipe once and every part inherits it through context; each * part composes via `render`. */const { withProvider, withContext } = createSlotRecipeContext(statSlotRecipe);
export const Stat = { // slot names resolve mechanically from the recipe maps above Root: withProvider("div", "root", "StatRoot"), Label: withContext("div", "label", "StatLabel"), ValueText: withContext("div", "valueText", "StatValueText"), ValueUnit: withContext("span", "valueUnit", "StatValueUnit"), HelpText: withContext("div", "helpText", "StatHelpText"), Indicator: withContext("span", "indicator", "StatIndicator"),};
Examples
Installable blocks built with Stat — real use cases, delivered as source you own.
Three-band analytics screen: a multi-series active-sessions chart and KPI sparkline tiles, audience stacked bar cards, and supporting top-routes and top-interactions activity tables.
Heterogeneous infrastructure spend and usage ledger organized into three collapsible schema-specific table cards (Compute & Inference Clusters, Storage & Data Lakes, Third-Party Integrations & APIs) with a shared global time-range selector, cross-section search, expand/collapse-all controls, per-section column sorting, and expandable rows revealing a TanStack Charts run-rate trajectory.
Edge runtime A/B benchmark comparison dashboard (v3.2 Candidate vs. v3.1 Baseline) with environment and metric controls, dual-series KPI sparkline cards, synchronized overlay and workload bar charts, distribution breakdowns, and a regional statistical-significance table.
Executive scorecard with a Q1–Q4 period switcher, KPI sparkline tiles, interactive ARR vs. plan TanStack Charts, segment mix and net-new ARR breakdowns, regional quota attainment table, strategic objectives tracker, and a narrative highlights rail.
Developer activation and cohort retention dashboard featuring KPI sparklines, a horizontal conversion funnel with step-to-step drop-off metrics, interactive W0–W8 retention curves and stage trends, and a clickable weekly cohort retention heatmap.
Treasury and infrastructure budget portfolio view with a period switcher, KPI summary tiles, historical reserve value curve, interactive allocation slices, stacked breakdown and budget-vs-actual bars, rate benchmark sparklines, and a filterable, sortable cost-center table.
Launch-readiness program tracker powered by TanStack Charts: release KPI sparklines, phase-filtered milestone Gantt with a Today marker, burndown vs. planned trajectory, sprint velocity, weighted scope allocation, blockers & risks callouts, and a health-filterable workstream progress table.
Live SRE service monitoring dashboard with time-range, service, and POP filters, TanStack Charts for latency percentiles, throughput, error rate, and KPI sparklines, 30-day SLO error budget meters, 90-day uptime strips, and a triage alert rail.
Application shell pairing a top navigation bar (workspace switcher, command search dialog, notifications popover, account menu) with a collapsible left sidebar, mobile slide-over drawer, and interactive cloud deployment views.
Left-rail application shell pairing a full-height collapsible sidebar (workspace switcher, quick actions, grouped route navigation, collapsible pinned collections with row menus, and user footer menu) with a mobile drawer fallback and interactive creative workspace views.
Top-navigation application shell with a centered horizontal Navbar (brand mark, route links, ⌘K command search dialog, notifications popover, account menu), mobile slide-over drawer fallback, and interactive public & internal operations views.
Editorial architectural monograph pairing a sticky left-hand project narrative, metadata list, metrics, and actions beside a vertical scrolling plate stack with a keyboard-navigable lightbox dialog.
Interactive design-system and token workbench featuring scoped accent, density, and corner-radius live preview controls over a responsive 3-column bento of cohesive UI SDK cards.