# DepthWedge (/docs/charts/depth-wedge)

Demand outweighs supply 1.42× and the spread is 1. DepthWedge draws the shape behind those numbers: demand accumulates
leftward from the spread and supply rightward, so two filled wedges carry the book's posture in a glyph, with the spread
— the gap between the best bid and the best ask — printed above the mid line. The y-scale is linear, full stop. A silent
log axis would exaggerate near-spread depth and flatter thin books, and log-depth reading belongs to full-size tools.

```tsx
import { DepthWedge } from "@microcharts/react/depth-wedge";

<DepthWedge data={{ demand, supply }} title="Order book" />
```

## Install

```tsx
import { DepthWedge } from "@microcharts/react/depth-wedge";

<DepthWedge data={{ demand, supply }} title="Order book" />
```

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 { DepthWedge } from "@microcharts/react/depth-wedge/interactive";

<DepthWedge
  data={{ demand, supply }}
/>
```

## When to use it

Use it for order-book depth or liquidity and for supply vs demand posture. For a time series reach for Sparkline; for a
single ratio, Delta.

## Sizing

**pair cell**

```tsx
<DepthWedge data={{ demand, supply }} label="none" width={60} height={16} />
```

**normalized**

```tsx
<DepthWedge data={{ demand, supply }} normalize />
```

## Variants

`normalize` plots cumulative shares per side instead of absolute amounts. `levels` sets how far from the mid the wedges
reach, and that visible range is part of the claim: whenever the summary names a leading side it scopes the ratio with
"within the shown range".

```tsx
<DepthWedge
  data={{
    demand: [
      { level: 99.5, amount: 420 },
      { level: 99, amount: 260 },
    ],
    supply: [
      { level: 100.5, amount: 300 },
      { level: 101, amount: 180 },
    ],
  }}
  normalize
/>
```

## Edge cases

```tsx
// equal totals per side — the summary states the balance instead of a lead
<DepthWedge
  data={{
    demand: [
      { level: 99.5, amount: 200 },
      { level: 99, amount: 100 },
    ],
    supply: [
      { level: 100.5, amount: 200 },
      { level: 101, amount: 100 },
    ],
  }}
/>
```

```tsx
// an empty side renders a single wedge; the spread is 0 (there is no gap
// to measure without both a best bid and a best ask)
<DepthWedge data={{ demand: [{ level: 99.5, amount: 200 }], supply: [] }} />
```

Equal totals per side make the summary state the balance rather than name a lead. An empty side renders a single wedge
and the spread reads 0, since there is no gap to measure without both a best bid and a best ask.

## Four homes

**In a sentence**

```tsx
<p>
  Order book depth{" "}
  <span className="mc-inline">
    <DepthWedge data={{ demand, supply }} summary={false} />
  </span>{" "}
  — bid-side liquidity thicker below mid.
</p>
```

**In a table cell**

```tsx
<td>
  <DepthWedge data={{ demand, supply }} />
</td>
```

**In a KPI card**

```tsx
<div className="kpi">
  <span className="figure">0.04</span>
  <span className="unit">bid/ask imbalance</span>
  <DepthWedge data={{ demand, supply }} />
</div>
```

**In a tab header**

```tsx
<button className="tab">
  BTC <DepthWedge data={{ demand, supply }} />
</button>
```

Best at KPI/card scale — book depth needs width to show both sides.

## Accessibility

The accessible name states the posture, scoped to the shown range: **"Demand outweighs supply 1.42× within the shown
range; spread 1."** — the hero demo's order book. The interactive entry walks the levels with ←/→, announcing the
cumulative depth on each side and its distance from the mid.

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) | `{ demand, supply }` | Level/amount rows per side. |
| `levels` | `number` | ± level distance from mid to include. |
| `normalize` | `boolean` | Plot cumulative shares per side. |
| `label` | `"spread" \| "none"` | The gap is the headline number. |
| `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).
