Sparkline
A tiny line chart without axes, for showing a trend inside a metric card.
<template> <MetricCard label="Total cost" :value="formatUsd(total)"> <template #chart> <Sparkline :data="daily" :value="(d) => d.costUsd" /> </template> </MetricCard></template>Props
| Name | Type | Default |
|---|---|---|
| data | T[] | - |
| value | (d: T) => number | null | - |
| color | string | "var(--color-chart-chart-1)" |
| height | number | 40 |
| ariaLabel | string | - |
Guidelines
Do
- Use it inside MetricCard's
#chartslot, under the value it illustrates - the card's label and value carry the meaning, the sparkline only shows the shape. - Return
nullfromvaluefor a missing point, same contract as TrendChart. - Pass a chart token (
var(--color-chart-chart-1)) ascolor- it is a plain CSS color string, no computed-style lookup needed.
Don't
- Don't use it where the reader needs to read a value off the chart - it has no axis, tooltip or legend. That is TrendChart's job.
- Don't pass
ariaLabelunless the sparkline says something the card's own text does not; by default it is decorative and hidden from assistive tech.