# Stat

A key figure with its label, an optional change against a named period and a sparkline.

- Family: display
- Import: `import { Stat, StatGroup } from "@senvenli/react/display";`
- Page: https://design.senvenli.com/docs/components/stat
- JSON: https://design.senvenli.com/docs/components/stat.json

## Example: Key figures in a row

Each change names the period it compares against; color follows whether the change is good, not its direction.

```tsx
import { Stat, StatGroup } from "@senvenli/react/display";

export default function Example() {
  return (
    <StatGroup aria-label="March 2026">
      <Stat label="Revenue" value="$48,920" delta={{ value: "12.4%", direction: "up" }} comparison="vs. February" />
      {/* Fewer refunds is good news, so the fall is marked positive. */}
      <Stat label="Refunds" value="18" delta={{ value: "25%", direction: "down", isPositive: true }} comparison="vs. February" />
      <Stat label="New customers" value="312" delta={{ value: "0%", direction: "flat" }} comparison="vs. February" />
    </StatGroup>
  );
}
```

## Examples

### With a sparkline

A short series under the figure shows the shape of the period.

```tsx
import { Stat } from "@senvenli/react/display";

const WEEKLY_ORDERS = [112, 126, 119, 138, 151, 147, 163, 172];

export default function Example() {
  return (
    <div className="max-w-xs">
      <Stat label="Orders" value="1,128" delta={{ value: "8.1%", direction: "up" }} comparison="vs. the previous 8 weeks" trend={WEEKLY_ORDERS} />
    </div>
  );
}
```

### A stat that is a link

The whole tile opens the report behind the figure.

```tsx
import { Stat } from "@senvenli/react/display";

export default function Example() {
  return (
    <div className="max-w-xs">
      <Stat label="Open invoices" value="$12,480" delta={{ value: "4.2%", direction: "up", isPositive: false }} comparison="vs. February" href="#" />
    </div>
  );
}
```

## Guidelines

### When to use it

- A dashboard's headline numbers.

### Use something else when

- [description-list](https://design.senvenli.com/docs/components/description-list.md): Several labeled facts about one record.

## Accessibility

Built in:

- The change is announced in words, not only by its arrow and color.
- Figures keep their formatted order in right-to-left pages.

You provide:

- A formatted value and, next to a change, the period it compares against.

## API reference

### Stat

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| label | `React.ReactNode` |  | yes |  |
| value | `React.ReactNode` |  | yes | The figure, already formatted with Intl ("$48,920"). |
| delta | `StatDelta` |  | no |  |
| comparison | `React.ReactNode` |  | no | The period the delta compares against ("vs. September"); required next to a delta. |
| trend | `number[]` |  | no | A short series for the sparkline. |
| href | `string` |  | no | Makes the whole tile a link to the report behind it. |

### StatGroup

| Prop | Type | Default | Required | Description |
| --- | --- | --- | --- | --- |
| children | `React.ReactNode` |  | yes |  |
| aria-label | `string` |  | no |  |

### Tokens it reads

`--ds-background-brand-subtle`, `--ds-border-focused`, `--ds-chart-1`, `--ds-easing-standard`, `--ds-icon`, `--ds-icon-brand`, `--ds-icon-danger`, `--ds-icon-information`, `--ds-icon-subtle`, `--ds-icon-success`, `--ds-icon-warning`, `--ds-radius-large`, `--ds-shadow-overlay`, `--ds-shadow-raised`, `--ds-size-icon`, `--ds-size-icon-large`, `--ds-size-icon-small`, `--ds-space-025`, `--ds-space-050`, `--ds-space-075`, `--ds-space-200`, `--ds-surface-raised`, `--ds-text`, `--ds-text-danger`, `--ds-text-subtle`, `--ds-text-subtlest`, `--ds-text-success`

## Related

- [description-list](https://design.senvenli.com/docs/components/description-list.md)
