Skip to content

Sparkline

Stable

A tiny trend line that highlights the latest value and can be read aloud.

Also known as mini chart, trend line

Install with npm install @tattva/ui (setup), or copy the code from the kit in Downloads.

Plain, and with lowest and highest points

The latest point has the main chart color. The line stays grey so the latest value stands out.

When to use it

A tiny trend line with the latest value marked, for places with no room for a full chart. It has no axes or labels, so it always sits beside a number.

Made of: Trend line · Lowest and highest dots · Latest point

Use it for

  • Beside a headline number, inside a StatTile.
  • A table cell or list row that shows a trend.
  • The fallback in a ChartFrame that is too narrow for the full chart.

Not for

  • A trend people need to read exact values from: use LineChart.
  • The only place the numbers appear: use DataTable.

Do and avoid

Orders this week

18.4K

Do. A tiny trend beside its number shows the shape at a glance.
Avoid. A lone line with no number gives nothing exact to read.

Do

  • Put it beside a number that gives the current value.
  • Cover the same time as the number beside it.
  • Use it in place of a chart that is too narrow to draw.

Avoid

  • Don't add axes, grid lines or labels. Use a LineChart for that.
  • Don't let a screen reader read it inside a tile. It would repeat the tile.
  • Don't compare trend lines as if they share a scale when they do not.

On a phone

  • It is a fixed-size picture, 96 by 28px unless you pass width and height, so it does not resize with its container.
  • It has no hover or tap behaviour, so put the numbers next to it in text.
  • Set width yourself if you need it larger on a phone.

Seen in products

  • PatternFly ships a sparkline alongside area, bar, line, pie and bullet charts, reported in the Supernova roundup.

Build your next AI screen with Tattva.

Free and open, with the code. Start in one line.

Get started