# ABStrips (/docs/charts/ab-strips)

ABStrips takes two samples of raw values, a control arm and a test arm, and draws **two graded quantile strips on one
shared scale**: a faint p5–95 band, a stronger p25–75 middle half, and a median dot, with row A muted and row B accent.
Whether the two middle halves still overlap is the read: while they do, the gap between the medians isn't a result yet.
The overlap number is always in the summary, because a delta without its spread doesn't say whether the two arms differ.
The strips are mandatory context: there is no bare-mean-bar mode, and the delta label never renders without the
distributions behind it.

```tsx
<ABStrips
  data={{
    a: Array.from({ length: 80 }, (_, i) => 130 + ((i * 13) % 44) - 22),
    b: Array.from({ length: 80 }, (_, i) => 116 + ((i * 13) % 44) - 22),
  }}
  format={{ style: "unit", unit: "millisecond", unitDisplay: "short", maximumFractionDigits: 0 }}
  positive="down"
  title="Latency A/B"
  width={260}
  height={26}
/>
```

## Install

```tsx
import { ABStrips } from "@microcharts/react/ab-strips";

const control = Array.from({ length: 80 }, (_, i) => 130 + ((i * 13) % 44) - 22);
const test = Array.from({ length: 80 }, (_, i) => 116 + ((i * 13) % 44) - 22);

<ABStrips data={{ a: control, b: test }} positive="down" title="Latency A/B" />
```

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

## Try it

```tsx
import { ABStrips } from "@microcharts/react/ab-strips/interactive";

<ABStrips
  data={{ a: control, b: test }}
  positive="down"
/>
```

## When to use it

Use it for an A/B experiment result in a KPI card, control vs test in an experiments table, and any two-sample
comparison where the spread matters. For a single distribution use BenchmarkStrip; for more than two arms use small
multiples.

## Sizing

**labelled arms**

```tsx
<ABStrips data={{ a: control, b: test }} seriesLabels={["Control", "Test"]} />
```

**clearly separated**

```tsx
<ABStrips data={{ a: slow, b: fast }} />
```

## Variants

```tsx
const control = Array.from({ length: 80 }, (_, i) => 130 + ((i * 13) % 44) - 22);
const test = Array.from({ length: 80 }, (_, i) => 116 + ((i * 13) % 44) - 22);

<ABStrips data={{ a: control, b: test }} seriesLabels={["Control", "Test"]} />
```

## Edge cases

```tsx
// an empty (or all-non-finite) arm renders no strips and announces "No data."
<ABStrips data={{ a: [], b: [110, 120, 130] }} />
```

```tsx
// fewer than 8 points in an arm: that row's outer band falls back to the
// observed min–max instead of p5–95 — tail quantiles are fiction at n < 8
<ABStrips data={{ a: [100, 130, 145], b: control80 }} />
```

Either arm with zero finite values makes the comparison unanswerable: no strips draw, and the accessible name reads
**"No data."** An arm with fewer than 8 points still draws. Only its outer band changes meaning, from the 5th–95th
percentile to the plain min–max, because tail percentiles need more than a handful of points to estimate.

## Four homes

**In a sentence**

```tsx
<p>
  Latency A/B this week{" "}
  <span className="mc-inline">
    <ABStrips data={{ a, b }} summary={false} />
  </span>{" "}
  — variant B wins by 12 ms on median.
</p>
```

**In a table cell**

```tsx
<td>
  <ABStrips data={{ a, b }} />
</td>
```

**In a KPI card**

```tsx
<div className="kpi">
  <span className="figure">−12 ms</span>
  <span className="unit">B vs A median</span>
  <ABStrips data={{ a, b }} />
</div>
```

**In a tab header**

```tsx
<button className="tab">
  checkout <ABStrips data={{ a, b }} />
</button>
```

## Accessibility

The accessible name states both medians, the delta, and the overlap — **"Test median 115 ms vs Ctrl 129 ms (-11%);
middle halves overlap 35%."**. When the middle halves fully overlap the summary says "no clear difference"; when they
are disjoint it says "clearly separated". The interactive entry roves the rows (↑/↓) and the quantile edges (←/→): the
median announces the delta vs the other arm, other edges announce the percentile.

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, press `Escape`, or
press outside the chart. On touch, a tap pins and a drag scrubs.

## Props

| Prop | Type | Description |
| --- | --- | --- |
| `data` (required) | `{ a: number[]; b: number[] }` | The two arms — raw samples, not summaries. |
| `seriesLabels` | `[string, string]` | Row identities for the gutter tags + summary (default ['A', 'B']). |
| `positive` | `"up" \| "down"` | Which direction of the B−A delta reads as good (colors the delta). |
| `label` | `"delta" \| "none"` | Signed median delta in a right gutter. |
| `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).
