Skip to content
TrademarkTrademark
Docs
Data

Sparkline

Updated: October 30, 2026
View on GitHub

Sparkline draws the shape of a series in the space of a line of text. It has no axes, legend, tooltip or card, and no recharts behind it: it is one SVG, so it renders in a server component and costs no JavaScript. The drawing stretches to its box (preserveAspectRatio="none") while the line keeps its width, so it fills a table cell or a tile at any size.

It fills its container's width and is 32px tall unless width and height say otherwise. A number is px; any CSS length, such as "100%" or "2rem", passes through. It also ships from the package root, as it pulls in nothing the root does not already have.

In a stat tile

The usual home of a sparkline: a number, the change, and the shape behind them. showLast puts a dot on the latest value.

In a table cell

Give the column a cell that draws the row's values. A fixed width keeps every row's line the same length.

Bars

variant="bar" draws one bar per value, from zero, so negative values hang below the line. With showLast the latest bar is in full colour and the rest are dimmed.

Curves and range

curve joins the points: "monotone" (the default, smooth and never past a point), "natural" (the charts' spline), "linear" or "step". min and max fix the values at the bottom and top edges, so sparklines side by side share a scale instead of each filling its own height.

Rows of data

Pass your rows as they are and name the key to plot with valueKey. Without it, the first key holding a number is used.

Accessibility

A sparkline is one image to a screen reader (role="img"). Without an aria-label it is named by a summary of its values, written in valueFormat and locale: the first example above reads "Trend from 120 to 340, high 360". Pass aria-label when the tile around it does not already say what the line is, such as "Revenue, last 8 weeks".

API reference

Type
Default
datarequired
The values, oldest first: numbers, or rows read by valueKey.
readonly number[]readonly T[]
—
valueKey
The row key to plot when data is objects. Defaults to the first key holding a number.
SeriesKey<T>—
variant
A line, a line with a filled area under it, or one bar per value.
lineareabar
line
color
A chart colour (blue, emerald), a token or any CSS colour.
ColorValueblue
width
A number is px; any CSS length passes through.
numberstring
100%
height
A number is px; any CSS length passes through.
numberstring
32
curve
How the line joins its points. Bars ignore it.
steplinearnaturalmonotone
monotone
showLast
A dot on the last point; on bars, the last bar in full colour.
booleanfalse
min
The value at the bottom edge. Defaults to the lowest value (0 or lower for bars).
number—
max
The value at the top edge. Defaults to the highest value (0 or higher for bars).
number—
valueFormat
How values are written in the summary a screen reader hears.
numbercompactpercentNumberFormatOptions(value: number) => string
—
locale
The locale the summary's numbers are written in.
string—
aria-label
What a screen reader hears, in place of the generated summary.
string—
Edit this page on GitHub