# RugStrip (/docs/charts/rug-strip)

RugStrip puts every value in a sample on one line as its own tick, so the full spread and the places the values crowd
read straight off the marks. Every tick is one real observation: no binning, no jitter, no thinning. Coincident values
darken through three opacity tiers (35%, 60%, 85%), so a lone tick stays visible while a stack reads as density; the
tiers are bucketed because a browser paints one path's stroke as a single operation, so the overlap compositing you
might expect never happens. `markValue` adds a full-height highlighted tick for one raw value against the field, which
is the strongest single read the strip offers; the regular ticks are inset by one unit so that highlight reads taller
without escaping the box.

```tsx
import { RugStrip } from "@microcharts/react/rug-strip";

<RugStrip data={salaries} markValue={78} title="Pay band" />
```

## Install

```tsx
import { RugStrip } from "@microcharts/react/rug-strip";

<RugStrip data={salaries} markValue={yourOffer} title="Pay band" />
```

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 { RugStrip } from "@microcharts/react/rug-strip/interactive";

<RugStrip
  data={salaries}
  markValue={yourOffer}
/>
```

## When to use it

Use it for a "you are here" read in a pay band, raw spread beside a stat, or margin composition under a Sparkline. Past
about 400 observations, reach for HistogramStrip: a rug promises raw marks and never downsamples. For trends over time
use Sparkline.

## Sizing

**you vs the field**

```tsx
<RugStrip data={salaries} markValue={78000}
  domain={[40000, 120000]} />
```

**fixed domain across rows**

```tsx
// same scale per row or the rugs lie
<RugStrip data={salaries} domain={[0, 200]} />
<RugStrip data={salaries.map((v) => v * 1.9)} domain={[0, 200]} />
```

## Variants

```tsx
<RugStrip data={field} markValue={62} />
```

```tsx
// coincident observations accumulate ink — that IS the density read
<RugStrip data={[50, 50, 50, 50, 62, 71]} />
```

```tsx
<RugStrip data={field} orientation="vertical" />
```

## Edge cases

```tsx
<RugStrip data={[]} title="No observations" />
```

Empty data draws a centered axis line rather than a blank hole, so the strip still reads as a rug with nothing on it
instead of a layout gap.

```tsx
<RugStrip data={[52]} title="One observation" />
```

A single value (or an all-equal field) has a zero-span domain; the tick renders at the strip's midpoint instead of
dividing by zero.

```tsx
<RugStrip data={[42, 48, 55, 61, 71]} markValue={120} />
```

A `markValue` outside the observed domain clamps to the nearest edge. It never escapes the box, and it never rescales
the field around itself.

## Four homes

**In a sentence**

```tsx
<p>
  Their $62k offer sits{" "}
  <span className="mc-inline">
    <RugStrip data={salaries} markValue={62} height={18} summary={false} />
  </span>{" "}
  inside the band, not at either edge.
</p>
```

**In a table cell**

```tsx
<td>
  <RugStrip data={salaries} markValue={62} width={64} height={18} />
</td>
```

**In a KPI card**

```tsx
<div className="kpi">
  <span className="figure">$62k</span>
  <span className="unit">inside the range</span>
  <RugStrip data={salaries} markValue={62} width={90} height={30} />
</div>
```

**In a tab header**

```tsx
<button className="tab">
  Engineering <RugStrip data={salaries} markValue={62} width={40} height={14} />
</button>
```

## Accessibility

The accessible name is the distribution: **"8 values from 42 to 75, median 59.5."** The interactive entry walks the
observations in sorted order and announces each one with its rank: **"48 — 2nd of 17."**

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) | `number[]` | Raw observations — position = value. |
| `markValue` | `number` | One value emphasized against the field. |
| `orientation` | `"horizontal" \| "vertical"` | Vertical rugs sit beside distributions. |
| `domain` | `[number, number]` | Fix the scale across rows (rugs mislead worst under per-row autoscale). |
| `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).
