Overview
A sparkline shows the shape of a series without axes, gridlines, or labels, so it fits beside the number it explains: a metric card, a table row, or a list of services. Use it to answer "which way is this going and how bumpy was it?" at a glance. When readers need exact values, dates, or comparisons between series, use a Line Chart instead.
Anatomy
Sparkline owns the data, the plotted dataKey, its colors, and the value scale. Choose a variant of line, area, or bar. Optional parts add context without adding chrome: Dot marks the latest point or the extremes, ReferenceLine draws a dashed baseline at a value or a statistic such as the average, and Tooltip reveals one point at a time on hover.
Accessibility
The canvas carries a generated accessible name that states the trend direction, the first and last values, and the range, for example "Revenue sparkline, up from $31.2k to $48.2k". Pass ariaLabel when the surrounding text already says this, or when the sparkline needs more specific wording. Keep the headline number in real text next to the chart; the tooltip is pointer-operated and must not be the only way to read a value.
Installation
Usage
import { Sparkline, type ChartConfig } from "honestui/charts";<Sparkline
data={data}
config={chartConfig}
dataKey="revenue"
xDataKey="week"
variant="area"
className="h-12 w-28"
>
<Sparkline.Dot points="last" />
<Sparkline.Tooltip valueFormatter={(value) => `$${value}k`} />
</Sparkline>Give the sparkline an explicit size. Its plot is inset only as far as the stroke and dots need, so the line reaches the edges of its box. The tooltip is attached to the page rather than the chart, so it can rise above a chart only a few pixels tall.
Examples
Variants
Lines suit continuous measures, areas add weight to a volume, and bars suit discrete counts such as daily signups. Bars start from zero unless the data has negative values; lines scale to the data range so small movements stay visible.
Dots and reference lines
ReferenceLine accepts a number or one of average, first, min, or max. Dot marks the last point, the extremes, both, or all points, using the same dot variants as the Line Chart.
In a table
Each row passes its own config, so one data key can take a rising or falling color. A reference line at the first value shows where the period started.
Loading State
A loading sparkline draws a neutral placeholder shape. A loading pill would not fit a chart this small, so the state is announced to assistive technology only.