Prodular UI

Sparkline

Pro

A tiny line, area or bar trend drawn in SVG without a chart library, colored with chart tokens through currentColor.

npx prodular-ui add sparkline

Part of Prodular UI Pro. Preview and read the docs freely, install with a license. See pricing

Variants

Line, area and bar. Each takes its color from the text color.

Line
Area
Bar

In a list

Next to a value in a row. Straight segments read better at very small sizes.

  • api-gateway182 ms
  • billing-worker640 ms
  • search-indexer96 ms
  • webhooks1.2 s

Anatomy

<Sparkline data={[12, 18, 15, 22, 28]} className="h-8 w-24 text-chart-1" showLastPoint />

Guidance

Use it when

  • Next to a number, to show which way it has been moving.
  • In table cells and KPI strips where a full chart would be too much.

Avoid

  • Anything people need to read exact values from. Use Chart with axes and tooltips.
  • Fewer than five points. A delta says more.

Rules for AI agents

Published in llms-full.txt, the registry and the MCP server, so coding agents follow them when they build with this component.

  • Size it with classes (h-6 w-20, or w-full) and color it with text-chart-1 to text-chart-5, or a status text token such as text-warning-subtle-foreground. Never pass hex colors.
  • Pass label when the trend matters to the reader; without it the sparkline is hidden from screen readers.
  • Pass data oldest first. Use variant="bar" for counts per period and line or area for continuous metrics.
  • Set min to 0 when the baseline matters, otherwise small changes look dramatic.

API

Sparkline

PropTypeDefaultDescription
datanumber[]The series, oldest first.
variant"line" | "area" | "bar""line"Shape.
curvedbooleantrueMonotone curve that never overshoots the data.
showLastPointbooleanfalseDot on the latest value.
strokeWidthnumber1.5Line width in px. It does not scale with the box.
min / maxnumberFix the y range, for example min={0}.
labelstringAccessible description. Without it the element is aria-hidden.

Installation

The Prodular UI CLI adds the source to components/ui with everything it depends on. In a project that already uses shadcn/ui, the shadcn CLI installs it from the Prodular registry too. See Installation for the first setup.

npx prodular-ui add sparkline# or, with the registry in components.jsonnpx shadcn@latest add @prodular/sparkline

Used in these screens