> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# KPI

> The kpi block shows a headline number with its change against the previous period or year, coloured by whether the change is good, and an optional sparkline.

A headline number with its change against the previous period.

```yaml theme={null}
type: kpi
metric: revenue
sparkline: true
```

[Live preview of the kpi component](https://hatchmark-preview.hatchmark.workers.dev/components/?embed=kpi\&theme=light)

The preview above is the live component gallery. [Open it full size](https://hatchmark-preview.hatchmark.workers.dev/#section=kpi) to switch between desktop and phone widths.

| Field | Meaning |
| - | - |
| `metric` | The metric to show. Its `label` is the KPI label unless `title` is set. |
| `compare` | `previous_period`, `previous_year` or `none`. Defaults to the dashboard period's compare. |
| `sparkline` | `true` adds a small line of the metric by month over the current window. |
| `span` | Width in the 12-column grid. Default 3, so four KPIs fill a row. |
| `height` | `compact`, `default` or `tall`: the size of the figure and the sparkline. |

What it draws:

* Consecutive KPI blocks share one card, split by hairlines (the KPI strip). On screens 1024 px
  and wider the strip draws every KPI at the tallest `height` among them, so figures in one strip
  match, and a KPI set lower gets warning HM2028. Below 1024 px the strip wraps and each KPI keeps
  its own `height`.
* `height` scales the figure and its sparkline together, in the Default theme (figure size / line
  height / sparkline height in px): `compact` 22/28/21, `default` 28/32/24, `tall` 36/44/33 on
  desktop; `compact` 18/24/20, `default` 20/28/24, `tall` 24/32/28 on phones.
* The figure is regular weight with tabular numbers. Currency switches to compact notation
  (`$6.14M`) at 100,000 and plain numbers at 1,000,000, unless the metric's format sets `compact`.
* The change carries an arrow and a sign: `▲ +10.0%`. Percent metrics change in percentage points:
  `▲ +0.27 pp`. The colour judges the change by the metric's `better`: `up` and `down` colour a
  rise good or bad, `neutral` leaves it grey. Metrics with `better: "down"` say "lower is better".
* The note names the comparison: "vs \$5.58M in Sep".
* The sparkline sits 12 px below the note. Hover, tap or focus it and use the arrow keys to see
  each month's value in the same tooltip as the line chart.
* An undefined value shows `—` with "No data in this period"; a real zero shows `$0`. With no
  previous value the note says "No Sep data to compare" and there is no change.

## Targets

`target: plan` names one of the metric's [targets](/docs/reference/metrics.md#targets). Three rows under the
note show it, the same three in every state so cards in a row line up and a card keeps its height
when a filter changes:

* The attainment, the value as a share of the pace while the period is in progress, else of the
  target: "103% of pace" or "112% of target", in the good or bad colour for a metric
  whose `better` is `up` or `down`. Good or bad compares the value with the pace or target
  directly, so a loss of $50 beats a loss ceiling of $100, and a value equal to its target counts as
  good whichever way is better. On a narrow card "of pace" drops; the note below names the numbers.
* A progress bar as wide as the larger of the value and the pace or target, with the pace or target
  as a tick. Short of it, the fill runs to the value and the rest of the bar up to the tick is the
  empty track. Past it, the fill spans the bar, the tick sits at target / value, and the fill past
  the tick is the surplus, drawn in a lighter shade of the same colour. The colour follows good or
  bad, so with `better: down` a fill short of the ceiling is good and a surplus past it is bad. A
  zero target with a positive value is all surplus. With no value, a negative value or target, or a
  value and target that are both zero, there is no bar; the row keeps its height.
* The pace and the target: "Pace $1.14M · FY plan $1.86M". A note too long for the card is cut at
  the end, with the full text on hover.

With no attainment the first row says why: "Target is zero or below", "No value to compare with the
target", "No FY plan for this period", or "FY plan hidden" with the reason on the note ("A segment
is on that the target can't follow"). Screen readers hear one sentence that says how far the value
is from the pace or target and which way, "less than 1%" when it is close but not level: "Revenue
is 3% ahead of its $1.14M pace; FY plan $1.86M",
"Refund rate is 18% above its 3.5% Refund ceiling, lower is better", or, with a zero or negative
target, the difference itself, in percentage points for a percent metric: "Revenue is $7,400 behind
its −$5,000 Loss ceiling".


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.