# MicroBox (/docs/charts/micro-box)

MicroBox answers "what are the p50 and spread of this metric?" — the five-number summary in a table row. Min-max
whiskers by default (Tukey fences imply a normality assumption most product data doesn't meet); `tukey` mode exposes
fence-breakers as dots.

```tsx
<MicroBox stats={{ min: 12, q1: 35, median: 42, q3: 51, max: 96 }} title="p95 latency" width={220} height={32} />
```

## Install

```tsx
import { MicroBox } from "@microcharts/react/micro-box";

<MicroBox stats={{ min: 12, q1: 35, median: 42, q3: 51, max: 96 }} title="p95 latency" />
```

Setup (package + stylesheet): [Quickstart](/docs/quickstart#set-up-with-an-ai-agent) or paste [`/agent-setup.md`](/agent-setup.md) into your agent.


## When to use it

- **Good for** — latency percentile rows (p50/p95/p99), spread beside a stat — precomputed `stats` is the production
  path.
- **Avoid for** — distribution shape (HistogramStrip) or fewer than 5 observations (renders honest dots).


## Variants

```tsx
const values = [...Array.from({ length: 20 }, (_, i) => 40 + i), 400, 500];

<MicroBox data={values} whiskers="tukey" />
```

## Edge cases

```tsx
// < 5 values → dots, never a fake box
<MicroBox data={[3, 7, 9]} />
```

```tsx
// a degenerate IQR collapses the box to a 1-unit tick; the domain pads
// ±1 around the value so the mark stays centered and visible
<MicroBox data={[7, 7, 7, 7, 7, 7]} />
```


## Why this default

Never a box from fewer than 5 observations — dots at the raw values instead. Precomputed `stats` with non-monotonic
values are refused with a dev warning: garbage in must not render a plausible-looking lie. Outlier dots cap at 3 per
side (the furthest).

## Accessibility

The accessible name is the five-number reading — **"Median 50.5, middle half 45.25 to 55.75, range 40 to 500."** The
interactive entry roves a fixed 5-stop model (min → Q1 → median → Q3 → max), announcing each stat (**"Median: 42."**).

The interactive entry follows the shared [interaction contract](/docs/accessibility#one-interaction-contract):
arrow keys rove between units on both axes, `Home` and `End` jump to the ends, and a click, tap, `Enter` or
`Space` selects a unit — pinning its readout so it survives blur, until you select it again or press `Escape`.
On touch, a tap pins and a drag scrubs.

## Props

| Prop | Type | Description |
| --- | --- | --- |
| `data` | `number[]` | Raw observations (exclusive with stats). |
| `stats` | `{ min; q1; median; q3; max }` | Precomputed server aggregates. |
| `whiskers` | `"minmax" \| "tukey"` | Tukey exposes outliers as dots. |
| `outliers` | `boolean` | Render outlier dots in tukey mode. |
| `animate` | `boolean` | (interactive) Opt-in entrance motion when the chart mounts client-side — add `import "@microcharts/react/motion"` once. Inert on the server, on hydrated server HTML, and under `prefers-reduced-motion`. |

Plus the shared grammar — `data`, `domain`, `color`, `title`, `summary`, `format` — and the layout props (`width`, `height`, `className`, `style`) that every chart accepts. Interactive entries also share `animate` and `live`, and — wherever a chart has more than one navigable unit — `onActive`, `onSelect`, `selectedIndex` and `defaultSelectedIndex`; and — wherever the chart shows a hover value — `readout`. See [the shared grammar](/docs/quickstart#the-shared-grammar).
