KPI card reference
Contents: Use cases, Chart IDs, Minimal spec, Data, Options, Annotations, Sizing, Fixtures, Not for.
Single-metric card: label, big value, up to two comparison pills, optional attainment, shape-only line/area/column sparkline with last observed value labeled. Type kpi.
Use cases
- Headline metric with trend
- Metric against PY and plan
- Dashboard tile
Chart IDs
One form; its chart ID is kpi.
Minimal spec
{
"type": "kpi",
"data": { "label": "Revenue", "value": 120, "delta": { "vs": 100, "scenario": "PY" } },
"options": { "unit": "$k", "title": "Revenue is $20k above prior year", "source": "Illustrative data" }
}Data
A cell is a number, null or a value object; see Value cell.
| Path | Type | Required | Meaning |
|---|---|---|---|
| label | string | yes | Name of the metric displayed above the main value. An empty string omits the label and its space. |
| value | number | yes | Main metric value in its original units. |
| format | string | Format-by-example for the main metric and absolute comparison values (a % example expects percent units: 3.53 for 3.53%). | |
| delta | object | Single scenario comparison; cannot be combined with compare. | |
| delta.vs | number | yes | Reference value subtracted from the main metric. |
| delta.scenario | string | AC, PY, PL, FC (or ACT, BUD, FCST, LY for last year). Codes and aliases accept any case. Code of the comparison baseline; a baseline with its own name, such as a month, goes in compare[].label instead. | |
| delta.direction | string | Whether an increase from the reference is favorable. neutral prints ordinary ink without a judgment; omission keeps higherIsBetter. One of 'higherIsBetter', 'lowerIsBetter', 'neutral'. | |
| delta.mode | string | Display absolute change, relative change, or both. Defaults to relative; under a percent format it defaults to absolute, which prints in pp. A zero or negative vs shows the absolute change with a ref-nonpositive warning, and a value on the other side of zero from vs shows it with a sign-change warning. One of 'absolute', 'relative', 'both'. | |
| compare | array | One or two named comparisons below the metric; cannot be combined with delta. An empty compare list is the same as none. | |
| compare[].vs | number | yes | Reference value for this named comparison. |
| compare[].label | string | yes | Visible name of this comparison baseline. |
| compare[].direction | string | Whether an increase from this reference is favorable. neutral prints ordinary ink without a judgment; omission keeps higherIsBetter. One of 'higherIsBetter', 'lowerIsBetter', 'neutral'. | |
| compare[].mode | string | Display absolute change, relative change, or both. Defaults to both; under a percent format it defaults to absolute, which prints in pp. A zero or negative vs shows the absolute change with a ref-nonpositive warning, and a value on the other side of zero from vs shows it with a sign-change warning. One of 'absolute', 'relative', 'both'. | |
| attainment | object | Ratio of the main value to a named target, displayed as attainment. | |
| attainment.vs | number | yes | Target value used as the attainment denominator. |
| attainment.label | string | yes | Visible name of the attainment target. |
| attainment.tone | string | Attainment tone. Omitted, it is the tone of the comparison against the same reference, else neutral. One of 'good', 'bad', 'warn', 'neutral'. | |
| bands | array | Qualitative bands for the main value, ascending by to. The band that holds the value sets the tone of the main value only; comparison tones stay separate. A band without a tone keeps the plain ink. A band label is added to the screen-reader text and the record. | |
| bands[].tone | string | Semantic band tone. One of 'good', 'warn', 'bad', 'neutral'. | |
| bands[].to | number | yes | Upper endpoint of this band in the value units. |
| bands[].label | string | Visible name of this band. | |
| note | string | Authored caption under the value: the basis, filter or scope the number is true of. Printed as written; the card never composes it. | |
| spark | object | Small trend chart displayed beneath the KPI comparison content. | |
| spark.kind | string | yes | Shape-only sparkline. 'column' and 'area' are zero-anchored. 'line' spans the series range. The last observed value is labeled unless the card's figure already prints it. No axes. One of 'line', 'area', 'column'. |
| spark.values | cell[] | yes | Trend observations in chronological order, in the same base units as the main value; the card format labels the last observed value unless it reads the same as the card's figure. A last value 1000 times or more off the main value is refused (spark-scale-mismatch). Missing cells create gaps. |
| spark.labels | array | One period name per value, such as 'W1' or 'Jan'. The card prints the first and the last under the spark's ends, so the reader sees the span. |
Options
| Path | Type | Values | Default | Meaning |
|---|---|---|---|---|
| labels | false | object | false (or another value of its type) | False hides comparisons and spark endpoint values. The main number, metric name and authored note remain. total: false explicitly hides the main number. | |
| columnOverrides | object | Settings per generated column. Ids: label, value. | ||
| columnOverrides.*.width | number | Track width in px. It beats the width the type would pick. | ||
| columnOverrides.*.align | string | 'left', 'right', 'center' | Alignment of the column: its cell text and, unless headAlign is set, its head. Bars keep starting at the panel origin. | |
| density | string | 'compact', 'regular' | 'regular' | Card density. 'compact' uses the smaller figure and spark share, and a 280 px default card width instead of 360. An unsized card takes its content height. 'regular' is the default. |
| comparisons | string | 'chip', 'text' | How compare[] and attainment are drawn. Omitted, a standalone regular card without a spark draws the steering form: the comparisons as rows of toned text with their names in a column, the attainment as a progress bar with a 100% tick, in one band on a wide card; a grid panel, a compact card, a card with a spark and a card whose height cannot hold the form draw chips. 'chip' tints a chip behind each; 'text' draws each as delta is drawn: text in its tone, no fill, compare entries on one row. colorblindSafe paints good and bad deltas, chips, attainment and value bands with the theme's color-blind pair. |
Plus the shared options. This type does not accept detailFields, labelPosition, valueAxis, story, hatchStrength, rounding, annotations. This type ignores animate, debug, rowLabels, categoryAxis, categoryLabels, secondaryAxis, sort, topN, bandFraction, legend, valueAxis.show, valueAxis.gridlines with an option-ignored warning.
Annotations
This type takes no annotations.
Sizing
Floor 120 × 28 px; fit content. Narrower than 280 px a card draws while its figure fits.
Below the floor a render is refused with size-below-floor and the pixels it needs. measure returns the natural and comfortable size for a given spec; see Sizing in the manual.
Fixtures
| ID | Kind | Use case |
|---|---|---|
| arr-card | example | ARR card with PY delta and area spark |
| churn-card | example | Net churn card: lowerIsBetter, negative delta reads good |
| dual-compare | example | Landing forecast with YoY, plan, and attainment steering chips |
| chip-comparisons | example | comparisons: 'chip' keeps the tinted chips on a standalone card |
| dual-compare-ref-nonpositive | torture | Torture: two nonpositive references show the absolute change in points |
| value-only | torture | Torture: no delta, no spark — value-only card with action title |
| unit-beside-value | torture | options.unit with no subtitle prints beside the value |
| vs-zero-guard | torture | Torture: vs=0 suppresses relative delta with ref-nonpositive |
| wide-value-long-label | torture | Torture: long label + $12,345,678,901 value forces font shrink |
| spark-nulls | torture | Torture: sparkline with null gaps breaks the line |
| spark-column | torture | Torture: column sparkline with a gap and last-value label |
| mode-both | torture | Torture: delta mode 'both' — percent and absolute in one pill |
| content-width-comparisons | example | KPI card stays within 420px in a wide host with comparisons and a spark |
| torture-long-labels | torture | Torture: long names at a generous size read whole, never cut |
| note-and-compact | example | Compact card pinned at 280 x 124, with the basis written under the value |
| text-comparisons | torture | Two comparisons as toned text with carets, one worse and one better, no chips |
| editorial-figure | example | Editorial card: a light serif figure from type.figure over text comparisons and a text attainment |
| spark-ink-pale-neutral | example | A line spark in the ink on a theme whose neutral is a pale sand |
| spark-area-as-line | example | An area spark drawn as a shape-only line ending in a ring, no wash and no end label |
| spark-area-from-min | example | An area spark whose scale and wash start at the series minimum |
| house-eyebrow | example | Tracked eyebrow from type.eyebrow, comparisons without carets |
| weekly-orders-card-spark | example | The bare weekly sparkline inside a card that names the measure, the period and the number |
| spark-ends-below-card | example | Cash card: today on the card, month-end balances in the spark, the last one labeled |
| attainment-bad-column-spark | torture | Attainment chip in the bad tone over a monthly column spark |
| compact-spark-floor | torture | Compact card keeps its sparkline readable |
| neutral-change | example | A change without a favorable direction |
| slot-natural-sizes | example | A card in a fixed slot that keeps its natural sizes at the top |
| value-bands | example | The band that holds the value colors the main value; the comparison keeps its own tone |
| column-overrides | example | columnOverrides sets the width and alignment of the comparison columns |
Not for
Several categories side by side; kpi shows one metric.