Sparkline
A word-sized line of a series — a trend next to a number, with no axes and no labels. It strokes in
currentColor from
a theme token, so it works in light and dark for every brand.Data Display
When to use
Use when
- Showing where a value has been going, beside the value itself: a score per week, cost per run.
- Dense rows and cards where a chart with axes does not fit.
Avoid when
- The reader needs the numbers, the scale or several series — use a chart or a table.
- One measurement on a scale — use
Meter. - Task progress — use
ProgressBar.
Usage
0.79
import { Sparkline } from '@apollion-dsi/core/data-display/sparkline';
<Sparkline values={[0.61, 0.64, 0.7, 0.68, 0.74, 0.79]} label="Fitness over 6 weeks, rising" />;values is the series, oldest first. Non-finite values are dropped; fewer than two points render nothing. The default
box is 64 × 20 px (width, height).
Colour
The line never guesses whether a rise is good news. Without color or higherIsBetter it stays neutral
(ink.secondary).
higherIsBettercompares the last point with the first:truepaints a risesuccessand a falldanger;falsereverses it. A flat series stays neutral.coloris a theme token and wins overhigherIsBetter. Never a raw colour.
<Sparkline values={fitness} label="Fitness over 5 weeks, rising" higherIsBetter />
<Sparkline values={cost} label="Cost per run over 5 days, rising" higherIsBetter={false} />
<Sparkline values={runs} label="Runs per day, last 5 days" color="information" />Accessibility
The SVG is role="img" named by label. Say the direction in the label (…, rising): colour alone never carries the
meaning.
Properties
Name
Type
Default
Description
color"main""primary""secondary""tertiary""success""information""warning""danger""primary.dark""primary.action""primary.light""primary.active""secondary.dark""secondary.action""secondary.light""secondary.active""tertiary.dark""tertiary.action""tertiary.light""tertiary.active""success.dark""success.action""success.light""success.active""information.dark""information.action""information.light""information.active""warning.dark""warning.action""warning.light""warning.active""danger.dark""danger.action""danger.light""danger.active""grayscale.0""grayscale.5""grayscale.10""grayscale.20""grayscale.30""grayscale.40""grayscale.50""grayscale.60""grayscale.70""grayscale.80""grayscale.90""grayscale.100""neutral.0""neutral.5""neutral.10""neutral.20""neutral.30""neutral.40""neutral.50""neutral.60""neutral.70""neutral.80""neutral.90""neutral.100""neutral.110""neutral.120""neutral.130""neutral.140""neutral.150""neutral.160""neutral.170""neutral.180""opposite""complementary""baseDark""baseLight""deepDark""deepLight""transparent""muted""surface.canvas""surface.sunken""surface.paper""surface.raised""surface.overlay""surface.scrim""ink.primary""ink.secondary""ink.muted""ink.disabled""edge.strong""edge.hairline""edge.border""wash.hover""wash.pressed""wash.selected"noneTheme colour token of the line (`primary`, `information`, `ink.muted`…).
Wins over `higherIsBetter`. Never a raw colour.
higherIsBetterbooleannoneColours the line by its direction (last point against the first):
`true` — rising is `success`, falling is `danger`; `false` — the
reverse (a cost, a latency). A flat series stays neutral. Ignored when
`color` is set; without either the line is neutral (`ink.secondary`).
label *stringnoneAccessible name — what the line shows and where it went
(`Fitness over 6 weeks, rising`). The line is `role="img"` named by it.
values *number[]noneThe series, oldest first. Non-finite values (`NaN`, `Infinity`) are
dropped; fewer than two remaining points renders nothing.
Beyond the props above,
Sparklineaccepts the native<span>attributes and the grid placement props (area,alignSelf,justifySelf), so it can sit in aGridslot directly.