# PairedBars (/docs/charts/paired-bars)

PairedBars answers "how does actual compare to expected, category by category?". Value and reference always share one
zero-anchored domain — comparing bars on different scales is the cardinal grouped-bar lie — and the reference is muted
by two structural cues (opacity _and_ width), never color alone.

```tsx
import { PairedBars } from "@microcharts/react/paired-bars";

<PairedBars data={[
  { label: "East", value: 940, ref: 1200 },
  { label: "West", value: 410, ref: 400 },
]} title="Actual vs plan" />
```

## Install

```tsx
import { PairedBars } from "@microcharts/react/paired-bars";

<PairedBars data={regions} title="Actual vs plan" />
```

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** — budget vs actual per region, target vs result rows.
- **Avoid for** — data without a reference series (MiniBar) or more than 5 pairs.


## Variants

```tsx
// the ghost is always the REFERENCE, never the value
<PairedBars
  data={[
    { label: "East", value: 940, ref: 1200 },
    { label: "West", value: 410, ref: 400 },
  ]}
  mode="overlay"
/>
```

```tsx
<PairedBars
  data={[
    { label: "East", value: 940, ref: 1200 },
    { label: "West", value: 410, ref: 400 },
  ]}
  positive="up"
/>
```

```tsx
<PairedBars
  data={[{ label: "East", value: 9400, ref: 12000 }]}
  locale="de-DE"
/>
```

The gap named in the summary follows `format`/`locale` — 12000 reads "12.000" under `de-DE` rather than the English
"12,000".

## Edge cases

```tsx
// value bar alone; the interactive entry announces "no reference"
<PairedBars data={[{ label: "East", value: 940, ref: null }]} />
```

```tsx
<PairedBars data={[{ label: "East", value: 940, ref: 1200 }]} />
```

A pair whose `ref` is `null` draws its value bar alone — no ghost, no zero-width placeholder — and the interactive entry
announces it as **"East: 940, no reference."** rather than pretending a comparison exists. Past 5 pairs the grouped read
blurs into noise, so the component still renders every pair but logs a dev warning.


## Why this default

Grouped over overlay by default — overlap hides small over-shoots, so the denser overlay form is the variant you choose
for tight cells, not the analytical default. A pair with a missing reference renders the value bar alone and announces
"no reference"; a chart where _every_ reference is missing dev-warns and steers to MiniBar.

## Accessibility

The accessible name leads with the largest gap — **"2 pairs. Largest gap East: 940 vs 1,200."** The interactive entry
roves pairs and announces each as value vs reference (**"East: 940 vs 1,200."**).

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` (required) | `{ label; value; ref }[]` | Value + reference per category. |
| `mode` | `"grouped" \| "overlay"` | Overlay puts the ref as a full-width ghost behind — halves the footprint. |
| `positive` | `"up" \| "down"` | Over/under-reference valence tint. |
| `orientation` | `"horizontal" \| "vertical"` | Rows for wide cells. |
| `locale` | `string \| string[]` | BCP 47 locale(s) for the gap named in the summary, e.g. "de-DE". |
| `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).
