Sparkline
A compact, interactive inline chart for showing a trend at a glance.
Usage
A Sparkline distills a series into a small, word-sized chart — the trend behind a KPI, a row in a table, a card header. Pass the numbers to the root's data; SparklineChart draws them. It comes in three layouts via variant: line, area (solid-filled to a baseline), and column (bars). A plain line can also take a decorative gradient fill down to the chart's edge.
The root holds the data and the hover state and hands them to the parts, so the optional SparklineValue and SparklineLabel can sit anywhere inside — a headline above the chart, say — and update as the pointer moves. Recolor everything through a single color prop, and read the hovered point from onActiveChange to render it wherever you like.
Examples
Line
The default. A crisp stroke with a hover indicator that snaps to the nearest point. The stroke stays sharp at any width because it doesn't scale with the chart.
Area
variant="area" is a conventional area chart: it's always filled with a solid tint between the curve and a baseline (0 by default). Values below the baseline fill below it — as in the second chart — so it reads as a signed magnitude, not just a trend. Move the reference line with baseline.
Filled line
A plain line is stroke-only. Add fill for a gradient that fades from the line down to the chart's bottom edge — the familiar "filled trend line" without a semantic baseline. This is the right choice for values far from zero, like a revenue KPI, where a true area chart would collapse into a solid block. (For a solid, baseline-anchored fill, use variant="area" instead.)
Columns
variant="column" renders bars, one per value, that pivot on a baseline (0 by default): values above it grow up, values below grow down — the standard signed bar sparkline, as in the second chart. Hovering highlights the active column. Best for discrete buckets — visits per day, net change per period. Move the pivot with baseline.
Line smoothing
curve controls how round the line is, from 0 (straight segments between points) to 1 (fully smoothed peaks). It applies to line and area.
Line weight
strokeWidth sets the line thickness in pixels (default 2). The stroke never scales with the chart, so it stays exactly this weight at any width.
Tooltip
Set tooltip to float the value at the hovered point. When the root has labels, the tooltip shows the matching label alongside the value; format controls the number's presentation.
Value headline
Drop SparklineValue and SparklineLabel inside the root to print the active point — or, when nothing is hovered, the last one. Combined with format, this is the classic "big number over a trend" stat. Since the values sit far from zero, this uses a gradient-filled line rather than an area chart. Hover the chart and the headline follows.
Reacting to the active point
For full control over where the reading appears, pass onActiveChange. It fires with the hovered { index, value, label } (or null on leave), so you can render the value anywhere — outside the chart, in a sibling panel, wherever.
Custom colors
color accepts any CSS color and drives the line, fill, indicator, and tooltip swatch. Reach for a theme token — var(--success-emphasis), var(--error-emphasis) — so it tracks light and dark mode, or pass a raw value like #a855f7 for a one-off.
RTL
Every Appica UI component supports right-to-left layouts out of the box. Set the dir attribute on a container (commonly your <html> element) so CSS logical properties resolve correctly, and wrap your tree in DirectionProvider so direction-aware behavior follows the same direction.
Under RTL the plot mirrors horizontally — the series reads right-to-left, columns stack from the right, and the hover mapping flips to match. For setup details and caveats, see the RTL guide.
API reference
Sparkline is a compound component. The root owns the data, formatting, and hover state; SparklineChart draws the visualization; SparklineValue and SparklineLabel print the active-or-last point. Each part forwards ref and its remaining native attributes to the underlying element.
Sparkline
The root and provider. Renders a <div> that lays its children out in a column, and exposes the accent color as the --sparkline-color CSS variable.
SparklineChart
The visualization. Renders a <div role="img"> wrapping an SVG (line/area) or bars (column), plus the hover indicator and tooltip overlays.
SparklineValue
Prints the hovered point's value — or the last point's when nothing is hovered — formatted with the root's format/locale. Renders a <span>.
SparklineLabel
Prints the hovered (or last) point's label from the root's labels. Renders nothing when no labels are provided. Renders a <span>.
SparklinePoint
The shape passed to onActiveChange and the render-function children.
Accessibility
SparklineChartrenders withrole="img"and anaria-label(defaulting to"{variant} chart"). Because a sparkline is a graphic, pass a descriptivearia-labelthat summarizes the trend — e.g."Revenue, up 40% over 7 days"— so screen-reader users get the meaning, not just the shape.- The indicator and tooltip are pointer affordances layered with
pointer-events-noneand markedaria-hidden; they never trap focus or intercept clicks. When a value needs to be readable, surface it as text viaSparklineValueoronActiveChange. - The indicator, tooltip, and column heights animate only under
motion-safe, so they stay still when the user prefers reduced motion.