Hacktron Design System

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
dataT[]-
value(d: T) => number | null-
colorstring"var(--color-chart-chart-1)"
heightnumber40
ariaLabelstring-

Guidelines

Do

  • Use it inside MetricCard's #chart slot, under the value it illustrates - the card's label and value carry the meaning, the sparkline only shows the shape.
  • Return null from value for a missing point, same contract as TrendChart.
  • Pass a chart token (var(--color-chart-chart-1)) as color - 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 ariaLabel unless the sparkline says something the card's own text does not; by default it is decorative and hidden from assistive tech.