---
title: "Stat · UI SDK — StyleX Blocks"
description: "Key figures with label, value, and help text in three value sizes."
url: "https://stylexblocks.com/components/ui-sdk/stat/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Stat

Key figures with label, value, and help text in three value sizes.

- Behavior engine: UI SDK
- Also available for: [Ark UI](https://stylexblocks.com/components/ark-ui/stat.md), [Base UI](https://stylexblocks.com/components/base-ui/stat.md)
- Category: Display
- Sizes: sm, md, lg
- Used in blocks: [Analytics Dashboard](https://stylexblocks.com/block/ui-sdk/analytics-dashboard.md), [Collapsible Table](https://stylexblocks.com/block/ui-sdk/collapsible-table.md), [Data Dashboard](https://stylexblocks.com/block/ui-sdk/data-dashboard.md), [Executive Dashboard](https://stylexblocks.com/block/ui-sdk/executive-dashboard.md), [Funnel & Cohort Dashboard](https://stylexblocks.com/block/ui-sdk/funnel-cohort-dashboard.md), [Portfolio Dashboard](https://stylexblocks.com/block/ui-sdk/portfolio-dashboard.md), [Project Status Dashboard](https://stylexblocks.com/block/ui-sdk/project-status-dashboard.md), [Service Monitoring](https://stylexblocks.com/block/ui-sdk/service-monitoring.md), [Shell Nav](https://stylexblocks.com/block/ui-sdk/shell-nav.md), [Side Nav Shell](https://stylexblocks.com/block/ui-sdk/shell-side-nav.md), [Top Nav Shell](https://stylexblocks.com/block/ui-sdk/shell-top-nav.md), [Side Gallery](https://stylexblocks.com/block/ui-sdk/side-gallery.md), [Theme Showcase](https://stylexblocks.com/block/ui-sdk/theme-showcase.md)
- HTML page: https://stylexblocks.com/components/ui-sdk/stat/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init --style ui-sdk
```

Then add the item as source you own:

```sh
npx stylexblocks add stat
```

Equivalent: `npx shadcn add @stylexblocks/stat`. Registry item JSON: https://stylexblocks.com/r/ui-sdk/stat.json

## Usage

```tsx
import { 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>
  );
}
```

## Source

`components/ui/ui-sdk/stat.tsx`

```tsx
import * 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 axis
const 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"),
};
```
