Skip to content
WunderUI

Sparkline

Pro

Small trend charts: KPI tiles, a metric list, a column strip and a win/loss strip, plus SparklineMini for tables and tiles.

Playground

Sparklines

MRR
34.1k+14.2%
Active users
8.4k+6.1%
Churn
2.1-0.4%
NPS
48+3%

Installation

Sparkline comes with WunderUI Core and Pro, in the package from your plan. See the plans.

The charts live in their own entry point: import the chart, its card and its hooks from @wunderui/react/charts, not from @wunderui/react.

Then import what you need:

tsx
import {
  Sparkline,
  SparklineMetric,
  SparklineMini,
  SparklineMiniProps,
  SparklineProps,
  SparklineVariant,
} from "@wunderui/react/charts"

Then use it:

tsx
import { SparklineMini } from "@wunderui/react/charts"

export function TrendCell() {
  return <SparklineMini data={[48, 50, 49, 53, 55, 54, 58, 61]} aria-label="Up 27 % over 8 days" />
}

Expected result: You see a small green trend line, 96 by 32 px, rising from left to right.

When to use

Use Sparkline for

  • A trend next to a number in a KPI tile or a metric list
  • A tiny trend in a table row (SparklineMini)
  • A daily strip of columns, or a win and loss strip, in a card

Use something else for

  • Line Chart for a trend with axes, a tooltip and a legend
  • Area Chart for volumes that need an axis
  • KPI for a single figure with a change
  • Metric Card for a card with a figure, a chart and a menu

States

Loading shows placeholders in the box of the tiles, so the layout does not move. There is no empty or error state: show an empty state or an alert in its place.

MRR
34.1k+14.2%
Active users
8.4k+6.1%
Churn
2.1-0.4%
NPS
48+3%

Sparkline Mini

SparklineMini is the trend line for a table row, tile or list: 96 by 32 px, or fluid to fill its cell (drawn at its real width, so the end dot stays round), with no axes or tooltip. It draws in and ends on a dot, like the end point of a Line chart. Colour follows direction, and an aria-label should say what it shows.

Hover and new data

Hover a SparklineMini and the line steps back while a short window around the point keeps its strength, with a dot on the point — the spotlight of the Line chart. onActiveIndexChange hands you the point, for example to show its value next to the line. New data, such as another period, morphs the line from where it is in half a second instead of drawing it in again.

Trends

  • MRR$34.1k
  • Active users8,420
  • Churn2.1%

Behavior and motion

What the sparkline draws and what it leaves to the page.

Hover
Sparklines take no focus and no keys; the accessible name carries the meaning, so write one that says what the trend is. The pointer follows the one hover model of the charts. SparklineMini dims the line and keeps a window around the hovered point, with a dot on it. The bar and win-loss strips keep the hovered bar at full strength (a pale bar comes up to full), dim the others to --chart-dim and show a compact tooltip beside the bar (labels name the values, tooltip={false} turns it off). Both hand the hovered index to onActiveIndexChange, for example to show its value next to the line.
Formats
KPI tiles and the metric list read metrics (label, value, change, points). The bar and win-loss strips read data, with height, colour and highlight options.
Direction
SparklineMini colours by direction (green up, red down, grey flat), and you can override it. The change in tiles and lists has a sign, so direction isn't only colour.
End point and new data
SparklineMini ends on a dot that arrives with the line (endPoint turns it off). New data morphs the line from where it is instead of drawing it in again; fluid draws at the cell's real width, so the dot stays round.
Loading
The loading state shows placeholders in the tiles' box, so the layout doesn't move when values arrive.

Motion

The enter sequence and the hover follow the library's motion tokens.

Count and draw
The number counts up to its value and the line draws in the first time the sparkline comes into view. You can turn it off.
Reduced motion
With reduced motion the enter sequence is off and the chart appears at once. Every state still works.

Anatomy

Sparkline covers the small trend formats: KPI tiles, a metric list, a column strip and a win/loss strip. SparklineMini is the 96 by 32 px trend line, with no axes or tooltip.

Sparklines

MRR
34.1k+14.2%
Active users
8.4k+6.1%
  • data-slot="sparkline"

    Picks a format: KPI tiles and a metric list read metrics (label, value, change, points), while the bar and win-loss strips read plain data. A loading state shows placeholders.

  • Optional

    The number, which counts up to its value, with the change under it (tiles) or beside it (list). It has a sign and a success or error colour, so direction isn't only colour.

  • Optional

    In the bar strip, one column per value with the highlighted bar solid and the rest pale. In the win-loss strip, green bars above the middle line and red below. The hovered bar keeps its strength and the others dim.

  • data-slot="sparkline-end"Optional
  • data-slot="sparkline-spotlight"Optional
  • data-slot="sparkline-active"Optional
  • data-slot="sparkline-mini"Optional

    The trend line, as line or area, 96 by 32 px by default or fluid to fill its cell, coloured by direction (green up, red down, grey flat). Give it an aria-label like Up 12.4% over 7 days.

Best practices

  • Do

    Always put the current value and the change next to the line. The line has no scale, so the number carries the meaning.

  • Do

    Set an aria-label with the direction and period on every SparklineMini. Without it the label is generated from the first and last value.

  • Do

    Use the same number of points and period for every row of a list. A seven-day line beside a 30-day line cannot be compared.

  • Don’t

    Don't compare the heights of two sparklines. Each is scaled to its own minimum and maximum, so a flat series and a volatile one can look alike.

  • Don’t

    Don't use the win-loss strip for values that aren't a result of a period. Positive means a win and anything else a loss.

API reference

Two tables: Sparkline, the formats that pair numbers with a trend, and SparklineMini, the trend line of a table row or a tile. Both are plain components with their own props.

Picks a format: KPI tiles and a metric list read metrics (label, value, change, points), while the bar and win-loss strips read plain data. A loading state shows placeholders.

PropTypeDefaultDescription
variant"kpi-tiles" | "metric-list" | "bar-sparkline" | "win-loss-sparkline""kpi-tiles"Figma variant. Default .
metricsreadonly SparklineMetric[][], : one metric per tile / row.
datareadonly number[][], : the values.
heightnumber48, : height of the strip (default 48).
color"indigo" | "blue" | "purple" | "green" | "orange" | "pink" | "yellow" | "red" | "grey"—: colour of the bars (default indigo).
highlightnumber—: the bar drawn solid (default the last one); the others are pale.
valueFormatter(v) => string(v) => String(v)
labelstring"Sparkline"
state"ready" | "loading" | "empty" | "error""ready"
labelsreadonly string[]—Bar and win-loss strips: names of the values (days, weeks) for the tooltip title. Default "3 of 12".
tooltipbooleantrueBar and win-loss strips: the compact tooltip beside the hovered bar. Default true.
onActiveIndexChange(index) => void—Bar and win-loss strips: called with the index of the hovered bar and with when the pointer leaves. Use it to show the hovered value in a headline.
animatebooleantrue

The trend line, as line or area, 96 by 32 px by default or fluid to fill its cell, coloured by direction (green up, red down, grey flat). Give it an aria-label like Up 12.4% over 7 days.

PropTypeDefaultDescription
data requiredreadonly (number | null | undefined)[]—
variant"line" | "area""line" or (Figma Sparkline Mini · Style).
trend"auto" | "up" | "down" | "neutral""auto"Colour by direction: compares first and last value (Figma · Trend).
color"indigo" | "blue" | "purple" | "green" | "orange" | "pink" | "yellow" | "red" | "grey"—Override the trend colour (token or palette name).
fluidbooleanfalseFill the parent's width (up to ) instead of a fixed size, for tiles and cards whose cells get narrow. The stroke keeps its weight.
widthnumber96Default 96 × 32 (Figma Sparkline Mini).
heightnumber32
animatebooleantrue
aria-labelstring—Accessible description, e.g. "Up 12 % over 7 days".
endPointbooleantrueA dot on the last value, like the end point of a Line chart. Default true.
onActiveIndexChange(index) => void—Called with the hovered point (pointer only) and with null when the pointer leaves, e.g. to show its value next to the line.

Notes for AI

Give your coding assistant the Markdown reference instead of screenshots.

MCPget_component("sparkline")
InstallIncluded in Core and Pro

The full library index for assistants is at /llms.txt.