# Micro stat

The figures under or beside a chart. ChangeIndicator is a movement with its verdict, toned by whether up is good or bad. MicroStat is a labelled figure. Both explain themselves in a tooltip.

Docs: https://ui.twelfth.ai/micro-stat · Category: Charts · Updated: 2026-10-30

## Install

```bash
npx shadcn@latest add https://ui.twelfth.ai/r/micro-stat.json
```

```tsx
import { ChangeIndicator, MicroStat } from "@/components/ui/micro-stat"
```

## Example

```tsx
<ChangeIndicator
  label="vs LY"
  value={6.2}
  higherIs="better"
  format={(n) => `${n}%`}
  flatWithin={1}
  strongAt={8}
  hint="How the change was measured"
/>
```

## A rise is good news

```tsx
<ChangeIndicator label="vs LY" value={6.2} higherIs="better" format={(n) => `${n}%`} />
```

## A rise is bad news

```tsx
<ChangeIndicator label="MAPE" value={7} higherIs="worse" format={(n) => `${n} pts`} strongAt={5} />
```

## Labelled figures

```tsx
<MicroStat label="OTB" value="$42k" hint="Open-to-buy left this month" />
```

## ChangeIndicator props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `value` (required) | `number \| null` |  | Signed change; null renders nothing. |
| `higherIs` (required) | `"better" \| "worse"` |  | Whether a rise is good news. |
| `label` | `string` |  | What moved, e.g. "vs LY". |
| `format` | `(magnitude) => string` |  | Formats the size of the change. |
| `flatWithin` | `number` | `0` | Changes this small read "flat". |
| `strongAt` | `number` |  | A worsening at least this large gets a filled chip. |
| `hint` | `ReactNode` |  | Explains how it was measured, in a tooltip. |

## MicroStat props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `label` (required) | `ReactNode` |  | e.g. "OTB". |
| `value` (required) | `ReactNode` |  | e.g. "$42k". |
| `hint` | `ReactNode` |  | Tooltip sentence. |

---

twelfth UI: Open-source (MIT) shadcn components for category managers and retail buying teams, by twelfth (https://twelfth.ai). React and TypeScript on shadcn's Base UI styles and Tailwind CSS v4. Components take plain props and fetch no data. Every block: https://ui.twelfth.ai/llms.txt
