Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

feat(core,cli): Stat component + kpi-dashboard template (Dashboard - KPI Summary) (#3329)

David Petersena9e99ac88383
diff --git a/apps/storybook/stories/Stat.stories.tsx b/apps/storybook/stories/Stat.stories.tsx
new file mode 100644
index 0000000000..736bf3157c
--- /dev/null
+++ b/apps/storybook/stories/Stat.stories.tsx
@@ -0,0 +1,110 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+import type {Meta, StoryObj} from '@storybook/react';
+import {Stat} from '@astryxdesign/lab';
+import {Card} from '@astryxdesign/core/Card';
+import {Grid} from '@astryxdesign/core/Grid';
+import {HStack, VStack} from '@astryxdesign/core/Layout';
+
+const meta: Meta<typeof Stat> = {
+ title: 'Lab/Stat',
+ component: Stat,
+ tags: ['autodocs'],
+ parameters: {
+ layout: 'centered',
+ },
+ decorators: [
+ Story => (
+ <div style={{width: 760, maxWidth: '100%'}}>
+ <Story />
+ </div>
+ ),
+ ],
+};
+
+export default meta;
+
+type Story = StoryObj<typeof Stat>;
+
+export const Showcase: Story = {
+ render: () => (
+ <Grid columns={{minWidth: 160, repeat: 'fit'}} gap={6}>
+ <Card>
+ <Stat
+ label="Total revenue"
+ value="$1.28M"
+ delta={{value: '+12.4%', direction: 'up'}}
+ description="vs. previous 30 days"
+ />
+ </Card>
+ <Card>
+ <Stat
+ label="Error rate"
+ value="0.42%"
+ delta={{value: '-0.08%', direction: 'down', sentiment: 'positive'}}
+ description="vs. previous 30 days"
+ />
+ </Card>
+ <Card>
+ <Stat
+ label="Active users"
+ value="18,204"
+ delta={{value: '0.0%', direction: 'flat'}}
+ description="vs. previous 30 days"
+ />
+ </Card>
+ </Grid>
+ ),
+};
+
+export const Sizes: Story = {
+ render: () => (
+ <HStack gap={8} vAlign="end">
+ <Stat
+ label="Deploys"
+ value="128"
+ size="sm"
+ delta={{value: '+6', direction: 'up'}}
+ />
+ <Stat
+ label="Deploys"
+ value="128"
+ size="md"
+ delta={{value: '+6', direction: 'up'}}
+ />
+ <Stat
+ label="Deploys"
+ value="128"
+ size="lg"
+ delta={{value: '+6', direction: 'up'}}
+ />
+ </HStack>
+ ),
+};
+
+export const WithMedia: Story = {
+ render: () => (
+ <Card>
+ <VStack gap={4}>
+ <Stat
+ label="Conversion"
+ value="7.8%"
+ delta={{value: '+0.9%', direction: 'up'}}
+ description="checkout completion"
+ media={
+ <svg viewBox="0 0 160 36" role="img" aria-label="Rising trend">
+ <polyline
+ points="0,28 24,26 48,30 72,18 96,20 120,10 160,8"
+ fill="none"
+ stroke="var(--color-accent)"
+ strokeWidth="3"
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ />
+ </svg>
+ }
+ />
+ </VStack>
+ </Card>
+ ),
+};
diff --git a/packages/lab/src/Stat/Stat.doc.mjs b/packages/lab/src/Stat/Stat.doc.mjs
new file mode 100644
index 0000000000..17ed3c7c67
--- /dev/null
+++ b/packages/lab/src/Stat/Stat.doc.mjs
@@ -0,0 +1,162 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/** @type {import('../../core/src/docs-types').ComponentDoc} */
+
+export const docs = {
+ name: 'Stat',
+ displayName: 'Stat',
+ category: 'Content',
+ keywords: ["stat","kpi","metric","number","value","delta","trend","dashboard","statistic","measure"],
+ props: [
+ {
+ name: 'label',
+ type: 'string',
+ description: 'Metric name shown above the value, e.g. "Total requests".',
+ required: true,
+ },
+ {
+ name: 'value',
+ type: 'ReactNode',
+ description:
+ 'Headline metric rendered large with tabular numerals. Pass a pre-formatted string like "1.2M".',
+ required: true,
+ },
+ {
+ name: 'delta',
+ type: "{value: string, direction: 'up' | 'down' | 'flat', sentiment?: 'positive' | 'negative' | 'neutral'}",
+ description:
+ 'Change indicator next to the value: an up/down/flat glyph plus colored text. sentiment overrides the direction color mapping (up=positive, down=negative, flat=neutral) for inverted metrics like error rate.',
+ },
+ {
+ name: 'description',
+ type: 'string',
+ description:
+ 'Muted supporting line under the value, e.g. "vs. previous 30 days".',
+ },
+ {
+ name: 'media',
+ type: 'ReactNode',
+ description:
+ 'Trend slot rendered below the text content, e.g. a sparkline or mini chart. Stat does not render a chart itself.',
+ },
+ {
+ name: 'size',
+ type: "'sm' | 'md' | 'lg'",
+ description: "Size variant controlling the value's font size.",
+ default: "'md'",
+ },
+ {
+ name: 'xstyle',
+ type: 'StyleXStyles',
+ description:
+ 'StyleX styles for layout customization (margins, positioning, sizing). Must be a stylex.create() value, not an inline style object like style={{}}.',
+ },
+ ],
+ theming: {
+ targets: [
+ {className: 'astryx-stat', visualProps: ['size']},
+ ],
+ },
+ usage: {
+ description:
+ 'A KPI/metric display for dashboards and summary rows: metric name, large tabular-nums value, an optional sentiment-aware delta, a supporting description, and a media slot for a sparkline or mini chart. Compose several in a Grid for a KPI row.',
+ bestPractices: [
+ { guidance: true, description: 'Pass pre-formatted strings for value and delta ("1.2M", "+12.4%"); Stat does not format numbers.' },
+ { guidance: true, description: 'Set `sentiment` explicitly for inverted metrics where down is good, like error rate or latency.' },
+ { guidance: true, description: 'Wrap Stat in a Card and lay out KPI rows with Grid columns={{minWidth: 240, max: 4}}.' },
+ { guidance: false, description: 'Put a full-size chart in the media slot; it is meant for compact sparklines or trend glyphs.' },
+ { guidance: false, description: 'Rely on delta color alone to convey meaning; the direction glyph and screen-reader text carry it too.' },
+ ],
+ },
+};
+
+/** @type {import('../../core/src/docs-types').ComponentDoc} */
+export const docsZh = {
+ name: 'Stat',
+ displayName: 'Stat',
+ props: [
+ {
+ name: 'label',
+ type: 'string',
+ description: '显示在数值上方的指标名称,例如 "Total requests"。',
+ required: true,
+ },
+ {
+ name: 'value',
+ type: 'ReactNode',
+ description:
+ '大号显示的核心指标,使用等宽数字。请传入预先格式化的字符串,如 "1.2M"。',
+ required: true,
+ },
+ {
+ name: 'delta',
+ type: "{value: string, direction: 'up' | 'down' | 'flat', sentiment?: 'positive' | 'negative' | 'neutral'}",
+ description:
+ '数值旁的变化指示:上升/下降/持平图标加彩色文本。sentiment 可覆盖默认的方向颜色映射(up=positive、down=negative、flat=neutral),用于错误率等反向指标。',
+ },
+ {
+ name: 'description',
+ type: 'string',
+ description: '数值下方的弱化辅助说明,例如 "vs. previous 30 days"。',
+ },
+ {
+ name: 'media',
+ type: 'ReactNode',
+ description:
+ '渲染在文本内容下方的趋势插槽,例如迷你折线图。Stat 本身不渲染图表。',
+ },
+ {
+ name: 'size',
+ type: "'sm' | 'md' | 'lg'",
+ description: '控制数值字号的尺寸变体。',
+ default: "'md'",
+ },
+ {
+ name: 'xstyle',
+ type: 'StyleXStyles',
+ description:
+ '用于布局自定义的 StyleX 样式(外边距、定位、尺寸)。必须是 stylex.create() 的值,而非内联样式对象如 style={{}}。',
+ },
+ ],
+ theming: {
+ targets: [
+ {className: 'astryx-stat', visualProps: ['size']},
+ ],
+ },
+ usage: {
+ description:
+ 'A KPI/metric display for dashboards and summary rows: metric name, large tabular-nums value, an optional sentiment-aware delta, a supporting description, and a media slot for a sparkline or mini chart. Compose several in a Grid for a KPI row.',
+ bestPractices: [
+ { guidance: true, description: 'Pass pre-formatted strings for value and delta ("1.2M", "+12.4%"); Stat does not format numbers.' },
+ { guidance: true, description: 'Set `sentiment` explicitly for inverted metrics where down is good, like error rate or latency.' },
+ { guidance: true, description: 'Wrap Stat in a Card and lay out KPI rows with Grid columns={{minWidth: 240, max: 4}}.' },
+ { guidance: false, description: 'Put a full-size chart in the media slot; it is meant for compact sparklines or trend glyphs.' },
+ { guidance: false, description: 'Rely on delta color alone to convey meaning; the direction glyph and screen-reader text carry it too.' },
+ ],
+ },
+};
+
+/** @type {import('../../core/src/docs-types').TranslationDoc} */
+export const docsDense = {
+ description: 'KPI/metric display: label, large tabular-nums value, sentiment-aware delta, and trend media slot.',
+ usage: {
+ description:
+ 'A KPI/metric display for dashboards and summary rows: metric name, large tabular-nums value, an optional sentiment-aware delta, a supporting description, and a media slot for a sparkline or mini chart. Compose several in a Grid for a KPI row.',
+ bestPractices: [
+ { guidance: true, description: 'Pass pre-formatted strings for value and delta ("1.2M", "+12.4%"); Stat does not format numbers.' },
+ { guidance: true, description: 'Set `sentiment` explicitly for inverted metrics where down is good, like error rate or latency.' },
+ { guidance: true, description: 'Wrap Stat in a Card and lay out KPI rows with Grid columns={{minWidth: 240, max: 4}}.' },
+ { guidance: false, description: 'Put a full-size chart in the media slot; it is meant for compact sparklines or trend glyphs.' },
+ { guidance: false, description: 'Rely on delta color alone to convey meaning; the direction glyph and screen-reader text carry it too.' },
+ ],
+ },
+ propDescriptions: {
+ label: 'Metric name above the value.',
+ value: 'Pre-formatted headline metric; tabular numerals.',
+ delta: 'Direction glyph + colored change text; sentiment overrides direction colors.',
+ description: 'Muted supporting line under the value.',
+ media: 'Trend slot below the text (sparkline/mini chart).',
+ size: "Value font size: 'sm' | 'md' | 'lg'.",
+ xstyle: 'StyleX layout styles; must be stylex.create() value.',
+ },
+};
diff --git a/packages/lab/src/Stat/Stat.test.tsx b/packages/lab/src/Stat/Stat.test.tsx
new file mode 100644
index 0000000000..c76e158350
--- /dev/null
+++ b/packages/lab/src/Stat/Stat.test.tsx
@@ -0,0 +1,143 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+import {describe, it, expect} from 'vitest';
+import {render, screen} from '@testing-library/react';
+import {Stat} from './Stat';
+
+describe('Stat', () => {
+ it('renders label and value', () => {
+ render(<Stat label="Total requests" value="2.4M" />);
+ expect(screen.getByText('Total requests')).toBeInTheDocument();
+ expect(screen.getByText('2.4M')).toBeInTheDocument();
+ });
+
+ it('renders the stable class and default size data attribute', () => {
+ render(<Stat label="Total requests" value="2.4M" data-testid="stat" />);
+ const root = screen.getByTestId('stat');
+ expect(root.classList.contains('astryx-stat')).toBe(true);
+ expect(root.getAttribute('data-size')).toBe('md');
+ });
+
+ it('reflects the size prop as a data attribute', () => {
+ render(
+ <Stat label="Total requests" value="2.4M" size="lg" data-testid="stat" />,
+ );
+ expect(screen.getByTestId('stat').getAttribute('data-size')).toBe('lg');
+ });
+
+ it('renders delta text with screen-reader direction', () => {
+ render(
+ <Stat
+ label="Total requests"
+ value="2.4M"
+ delta={{value: '+12.4%', direction: 'up'}}
+ />,
+ );
+ expect(screen.getByText('+12.4%')).toBeInTheDocument();
+ expect(screen.getByText('(trending up)')).toBeInTheDocument();
+ });
+
+ it('maps direction to default sentiment', () => {
+ render(
+ <Stat
+ label="P95 latency"
+ value="284 ms"
+ delta={{value: '+18 ms', direction: 'up'}}
+ />,
+ );
+ const delta = screen.getByText('+18 ms');
+ expect(delta.getAttribute('data-sentiment')).toBe('positive');
+ });
+
+ it('maps down direction to negative sentiment by default', () => {
+ render(
+ <Stat
+ label="Signups"
+ value="1,204"
+ delta={{value: '-4.1%', direction: 'down'}}
+ />,
+ );
+ expect(screen.getByText('-4.1%').getAttribute('data-sentiment')).toBe(
+ 'negative',
+ );
+ });
+
+ it('maps flat direction to neutral sentiment by default', () => {
+ render(
+ <Stat
+ label="Active users"
+ value="18,204"
+ delta={{value: '0.0%', direction: 'flat'}}
+ />,
+ );
+ expect(screen.getByText('0.0%').getAttribute('data-sentiment')).toBe(
+ 'neutral',
+ );
+ expect(screen.getByText('(flat)')).toBeInTheDocument();
+ });
+
+ it('lets sentiment override the direction mapping for inverted metrics', () => {
+ render(
+ <Stat
+ label="Error rate"
+ value="0.42%"
+ delta={{value: '-0.08%', direction: 'down', sentiment: 'positive'}}
+ />,
+ );
+ const delta = screen.getByText('-0.08%');
+ expect(delta.getAttribute('data-sentiment')).toBe('positive');
+ expect(screen.getByText('(trending down)')).toBeInTheDocument();
+ });
+
+ it('renders the description when provided', () => {
+ render(
+ <Stat
+ label="Total requests"
+ value="2.4M"
+ description="vs. previous 30 days"
+ />,
+ );
+ expect(screen.getByText('vs. previous 30 days')).toBeInTheDocument();
+ });
+
+ it('renders media content when provided', () => {
+ render(
+ <Stat
+ label="Total requests"
+ value="2.4M"
+ media={<svg data-testid="sparkline" />}
+ />,
+ );
+ expect(screen.getByTestId('sparkline')).toBeInTheDocument();
+ });
+
+ it('does not render a delta glyph without a delta', () => {
+ const {container} = render(<Stat label="Total requests" value="2.4M" />);
+ expect(container.querySelector('svg')).toBeNull();
+ });
+
+ it('forwards ref', () => {
+ const ref = {current: null as HTMLDivElement | null};
+ render(<Stat ref={ref} label="Total requests" value="2.4M" />);
+ expect(ref.current).toBeInstanceOf(HTMLDivElement);
+ });
+
+ it('supports data-testid', () => {
+ render(<Stat label="Total requests" value="2.4M" data-testid="stat" />);
+ expect(screen.getByTestId('stat')).toBeInTheDocument();
+ });
+
+ it('accepts a ReactNode value', () => {
+ render(
+ <Stat
+ label="Uptime"
+ value={
+ <span>
+ 99.98<small>%</small>
+ </span>
+ }
+ />,
+ );
+ expect(screen.getByText('99.98')).toBeInTheDocument();
+ });
+});
diff --git a/packages/lab/src/Stat/Stat.tsx b/packages/lab/src/Stat/Stat.tsx
new file mode 100644
index 0000000000..242d60036b
--- /dev/null
+++ b/packages/lab/src/Stat/Stat.tsx
@@ -0,0 +1,298 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+'use client';
+
+/**
+ * @file Stat.tsx
+ * @input Uses React, StyleX, and Astryx core theme tokens/utilities
+ * @output Exports Stat component, StatProps, StatDelta, StatDeltaDirection,
+ * StatDeltaSentiment, StatSize types
+ * @position Lab implementation; consumed by packages/lab/src/index.ts
+ *
+ * SYNC: When modified, update these files to stay in sync:
+ * - /packages/lab/src/Stat/Stat.doc.mjs (props table, features, implementation notes)
+ * - /packages/lab/src/Stat/Stat.test.tsx (tests for new/changed behavior)
+ * - /packages/lab/src/Stat/index.ts (exports if types change)
+ * - /apps/storybook/stories/Stat.stories.tsx (examples)
+ */
+
+import type {ReactNode} from 'react';
+import * as stylex from '@stylexjs/stylex';
+import {
+ colorVars,
+ fontWeightVars,
+ spacingVars,
+ textSizeVars,
+ typeScaleVars,
+ typographyVars,
+} from '@astryxdesign/core/theme/tokens.stylex';
+import type {BaseProps} from '@astryxdesign/core';
+import {mergeProps} from '@astryxdesign/core/utils';
+import {themeProps} from '@astryxdesign/core/utils';
+
+/**
+ * Base styles
+ */
+const styles = stylex.create({
+ base: {
+ display: 'flex',
+ flexDirection: 'column',
+ alignItems: 'flex-start',
+ gap: spacingVars['--spacing-1'],
+ minWidth: 0,
+ },
+ label: {
+ fontSize: typeScaleVars['--text-supporting-size'],
+ lineHeight: typeScaleVars['--text-supporting-leading'],
+ fontWeight: fontWeightVars['--font-weight-medium'],
+ color: colorVars['--color-text-secondary'],
+ },
+ valueRow: {
+ display: 'flex',
+ alignItems: 'baseline',
+ gap: spacingVars['--spacing-2'],
+ minWidth: 0,
+ },
+ value: {
+ fontFamily: typographyVars['--font-family-heading'],
+ fontWeight: fontWeightVars['--font-weight-semibold'],
+ lineHeight: typeScaleVars['--text-heading-2-leading'],
+ color: colorVars['--color-text-primary'],
+ fontVariantNumeric: 'tabular-nums',
+ },
+ delta: {
+ display: 'inline-flex',
+ alignItems: 'center',
+ gap: spacingVars['--spacing-1'],
+ fontSize: typeScaleVars['--text-supporting-size'],
+ lineHeight: typeScaleVars['--text-supporting-leading'],
+ fontWeight: fontWeightVars['--font-weight-medium'],
+ fontVariantNumeric: 'tabular-nums',
+ whiteSpace: 'nowrap',
+ },
+ deltaGlyph: {
+ flexShrink: 0,
+ },
+ description: {
+ fontSize: typeScaleVars['--text-supporting-size'],
+ lineHeight: typeScaleVars['--text-supporting-leading'],
+ color: colorVars['--color-text-secondary'],
+ },
+ media: {
+ marginTop: spacingVars['--spacing-1'],
+ alignSelf: 'stretch',
+ minWidth: 0,
+ },
+ srOnly: {
+ position: 'absolute',
+ width: '1px',
+ height: '1px',
+ padding: 0,
+ margin: '-1px',
+ overflow: 'hidden',
+ clip: 'rect(0 0 0 0)',
+ whiteSpace: 'nowrap',
+ borderWidth: 0,
+ },
+});
+
+/**
+ * Value font-size per size variant
+ */
+const sizeStyles = stylex.create({
+ sm: {
+ fontSize: textSizeVars['--font-size-xl'],
+ },
+ md: {
+ fontSize: textSizeVars['--font-size-2xl'],
+ },
+ lg: {
+ fontSize: textSizeVars['--font-size-3xl'],
+ },
+});
+
+/**
+ * Delta color per resolved sentiment
+ */
+const sentimentStyles = stylex.create({
+ positive: {
+ color: colorVars['--color-success'],
+ },
+ negative: {
+ color: colorVars['--color-error'],
+ },
+ neutral: {
+ color: colorVars['--color-text-secondary'],
+ },
+});
+
+/** Trend direction of a delta; picks the glyph (up/down arrow, flat dash). */
+export type StatDeltaDirection = 'up' | 'down' | 'flat';
+
+/** Color tone of a delta; overrides the default direction mapping. */
+export type StatDeltaSentiment = 'positive' | 'negative' | 'neutral';
+
+/** Size variant controlling the value's font size. */
+export type StatSize = 'sm' | 'md' | 'lg';
+
+/**
+ * Change indicator rendered next to the value: a direction glyph plus
+ * colored, pre-formatted change text.
+ */
+export interface StatDelta {
+ /** Pre-formatted change text, e.g. "+12.4%" or "-8 ms". */
+ value: string;
+ /** Trend direction. Picks the glyph and the default sentiment. */
+ direction: StatDeltaDirection;
+ /**
+ * Overrides the direction-to-color mapping for inverted metrics where
+ * down is good (error rate, latency): up maps to positive, down to
+ * negative, flat to neutral by default.
+ */
+ sentiment?: StatDeltaSentiment;
+}
+
+/** Default direction-to-sentiment mapping (up=good, down=bad). */
+const DIRECTION_SENTIMENT: Record<StatDeltaDirection, StatDeltaSentiment> = {
+ up: 'positive',
+ down: 'negative',
+ flat: 'neutral',
+};
+
+/** Screen-reader text announced after the delta value. */
+const DIRECTION_TEXT: Record<StatDeltaDirection, string> = {
+ up: 'trending up',
+ down: 'trending down',
+ flat: 'flat',
+};
+
+/** Inline glyph paths (12x12 viewBox): up-right arrow, down-right arrow, dash. */
+const DELTA_GLYPH_PATHS: Record<StatDeltaDirection, string> = {
+ up: 'M3.5 8.5L8.5 3.5M8.5 3.5H4.75M8.5 3.5V7.25',
+ down: 'M3.5 3.5L8.5 8.5M8.5 8.5H4.75M8.5 8.5V4.75',
+ flat: 'M2.5 6H9.5',
+};
+
+export interface StatProps extends BaseProps<HTMLElement> {
+ /** Ref forwarded to the root element */
+ ref?: React.Ref<HTMLDivElement>;
+ /**
+ * Metric name shown above the value, e.g. "Total requests".
+ */
+ label: string;
+ /**
+ * The headline metric. Rendered large with tabular numerals so digits
+ * keep a fixed width. Pass a pre-formatted string like "1.2M".
+ */
+ value: ReactNode;
+ /**
+ * Change indicator rendered next to the value: an up/down/flat glyph
+ * plus colored text. `sentiment` overrides the direction color mapping
+ * for inverted metrics like error rate.
+ */
+ delta?: StatDelta;
+ /**
+ * Muted supporting line under the value, e.g. "vs. previous 30 days".
+ */
+ description?: string;
+ /**
+ * Trend slot rendered below the text content, e.g. a sparkline or mini
+ * chart. Stat does not render a chart itself.
+ */
+ media?: ReactNode;
+ /**
+ * Size variant controlling the value's font size.
+ * @default 'md'
+ */
+ size?: StatSize;
+}
+
+/**
+ * A KPI/metric display: label, large tabular-nums value, optional
+ * sentiment-aware delta, supporting description, and a trend media slot.
+ *
+ * The delta's color follows its direction (up=success, down=error,
+ * flat=secondary) unless `sentiment` overrides it — use that for inverted
+ * metrics where a drop is good (error rate, latency, churn).
+ *
+ * Styles use Astryx theme tokens via StyleX.
+ * Wrap your app in `<Theme>` to apply a theme.
+ *
+ * @example
+ * ```
+ * <Stat label="Total requests" value="2.4M" delta={{value: '+12.4%', direction: 'up'}} />
+ * <Stat
+ * label="Error rate"
+ * value="0.42%"
+ * delta={{value: '-0.08%', direction: 'down', sentiment: 'positive'}}
+ * description="vs. previous 30 days"
+ * />
+ * <Stat label="Active users" value="18,204" size="lg" media={<Sparkline />} />
+ * ```
+ */
+export function Stat({
+ label,
+ value,
+ delta,
+ description,
+ media,
+ size = 'md',
+ xstyle,
+ className,
+ style,
+ ref,
+ ...props
+}: StatProps) {
+ const sentiment =
+ delta == null
+ ? null
+ : (delta.sentiment ?? DIRECTION_SENTIMENT[delta.direction]);
+
+ return (
+ <div
+ ref={ref}
+ {...mergeProps(
+ themeProps('stat', {size}),
+ stylex.props(styles.base, xstyle),
+ className,
+ style,
+ )}
+ {...props}>
+ <span {...stylex.props(styles.label)}>{label}</span>
+ <span {...stylex.props(styles.valueRow)}>
+ <span {...stylex.props(styles.value, sizeStyles[size])}>{value}</span>
+ {delta != null && sentiment != null ? (
+ <span
+ data-sentiment={sentiment}
+ {...stylex.props(styles.delta, sentimentStyles[sentiment])}>
+ <svg
+ aria-hidden="true"
+ viewBox="0 0 12 12"
+ width={12}
+ height={12}
+ fill="none"
+ stroke="currentColor"
+ strokeWidth={1.5}
+ strokeLinecap="round"
+ strokeLinejoin="round"
+ {...stylex.props(styles.deltaGlyph)}>
+ <path d={DELTA_GLYPH_PATHS[delta.direction]} />
+ </svg>
+ {delta.value}
+ <span {...stylex.props(styles.srOnly)}>
+ ({DIRECTION_TEXT[delta.direction]})
+ </span>
+ </span>
+ ) : null}
+ </span>
+ {description != null ? (
+ <span {...stylex.props(styles.description)}>{description}</span>
+ ) : null}
+ {media != null ? (
+ <div {...stylex.props(styles.media)}>{media}</div>
+ ) : null}
+ </div>
+ );
+}
+
+Stat.displayName = 'Stat';
diff --git a/packages/lab/src/Stat/index.ts b/packages/lab/src/Stat/index.ts
new file mode 100644
index 0000000000..7c3075db56
--- /dev/null
+++ b/packages/lab/src/Stat/index.ts
@@ -0,0 +1,19 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+'use client';
+
+/**
+ * @file index.ts
+ * @input Imports from Stat component
+ * @output Exports Stat component and related types
+ * @position Entry point for Stat; re-exported by /packages/lab/src/index.ts
+ */
+
+export {Stat} from './Stat';
+export type {
+ StatProps,
+ StatDelta,
+ StatDeltaDirection,
+ StatDeltaSentiment,
+ StatSize,
+} from './Stat';
diff --git a/packages/lab/src/index.ts b/packages/lab/src/index.ts
index e3caed21a0..bd1a765c61 100644
--- a/packages/lab/src/index.ts
+++ b/packages/lab/src/index.ts
@@ -35,6 +35,16 @@ export * from './Chat';
// Drawer — experimental overlay panel
export {Drawer, type DrawerProps} from './Drawer';
+// Stat — experimental KPI/metric display
+export {
+ Stat,
+ type StatProps,
+ type StatDelta,
+ type StatDeltaDirection,
+ type StatDeltaSentiment,
+ type StatSize,
+} from './Stat';
+
// Schedule — experimental full-calendar views
export * from './Schedule';