# TimeInRange (/docs/charts/time-in-range)

72% in range, 9% below, 19% above. TimeInRange prints the share of a period that stayed inside its corridor and which
side the rest missed on, with the in-range percent leading. Zones sit in a fixed order (below, in, above), so the strip
reads by position first and color second. They are never sorted by magnitude, because which side a miss landed on is
half the reading.

```tsx
<TimeInRange data={{ below: 9, in: 72, above: 19 }} title="Time in range" width={240} height={22} />
```

## Install

```tsx
import { TimeInRange } from "@microcharts/react/time-in-range";

<TimeInRange data={{ below: 9, in: 72, above: 19 }} title="Time in range" />
```

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 { TimeInRange } from "@microcharts/react/time-in-range/interactive";

<TimeInRange
  data={{ below: 9, in: 72, above: 19 }}
/>
```

## When to use it

Use it for SLO and uptime corridors, glucose-style time-in-range, and thermal or budget bands. To rank parts use
SegmentedBar; for a single ratio use Progress.

## Sizing

**table cell**

```tsx
<TimeInRange data={row.tir} width={60} height={10} />
```

**clinical column**

```tsx
<TimeInRange data={tir} orientation="vertical" label="all" />
```

## Variants

```tsx
<TimeInRange
  data={{ severeBelow: 2, below: 7, in: 72, above: 15, severeAbove: 4 }}
  orientation="vertical"
  label="all"
/>
```

```tsx
<TimeInRange data={{ severeBelow: 3, below: 8, in: 64, above: 18, severeAbove: 7 }} />
```

Severity tiers are drawn in the same hue at greater ink weight, so a severe zone never depends on color alone.

## Edge cases

```tsx
// all-zero data renders an empty strip, never a misleading full bar
<TimeInRange data={{ below: 0, in: 0, above: 0 }} title="No readings yet" />
```

```tsx
// label="all" only shows a percent where the zone is wide enough to seat it —
// the tiny below/above slivers here drop their text instead of overlapping
<TimeInRange data={{ below: 3, in: 90, above: 7 }} label="all" width={60} height={10} />
```

Percent labels use largest-remainder rounding, so they always sum to 100 and the summary reads the same integers as the
labels.

## Four homes

**In a sentence**

```tsx
<p>
  Glucose time-in-range{" "}
  <span className="mc-inline">
    <TimeInRange data={{ below: 9, in: 72, above: 19 }} summary={false} />
  </span>{" "}
  — 72% in range, 9% below.
</p>
```

**In a table cell**

```tsx
<td>
  <TimeInRange data={{ below: 9, in: 72, above: 19 }} />
</td>
```

**In a KPI card**

```tsx
<div className="kpi">
  <span className="figure">72%</span>
  <span className="unit">glucose TIR</span>
  <TimeInRange data={{ below: 9, in: 72, above: 19 }} />
</div>
```

**In a tab header**

```tsx
<button className="tab">
  Patient A <TimeInRange data={{ below: 9, in: 72, above: 19 }} />
</button>
```

## Accessibility

The accessible name leads with the headline, then the misses: **"72% in range, 7% below, 15% above, 2% severe low, 4%
severe high."** The interactive entry roves the zones, and each announces its share (**"in range: 72%."**).

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) | `TimeInRangeDatum` | Counts or fractions; normalized to 1. |
| `orientation` | `"horizontal" \| "vertical"` | Vertical suits clinical columns and KPI cards. |
| `label` | `"in" \| "all" \| "none"` | The in-range headline, a full audit, or clean. |
| `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).
