Sparkline

A small, inline trend chart with no axes or labels.

Import

import { Sparkline } from '@matix/charts/sparkline';

Usage

Area variant

API Reference

PropTypeDefaultDescription
dataChartPoint[]—Single series. y: null renders as a gap.
widthnumber120Fixed px width — inline element, not responsive.
heightnumber32Fixed px height.
variant'line' | 'area''line''area' adds a soft fill under the line.
curve'straight' | 'curved''curved'Line interpolation.
animatebooleanfalseCSS draw-in on mount. Usually left off for spark in a stat tile.
colorIndexnumber0Palette slot when composing multiple sparklines.
labelstring—Accessible description. Required for a11y — omitting renders aria-hidden.
sxStyleXStyles—StyleX style override

Accessibility

  • Renders an <svg> with role="img" and aria-label={label} when label is provided.
  • Without label, the <svg> renders aria-hidden="true" — there is no default label that could lie about what the trend shows.
  • description adds a richer hidden summary. aria-describedby links consumer-owned text, and accessibleData supplies custom hidden React content when the surrounding UI does not already expose the values.
  • Sparklines do not generate a data table automatically because they are normally supplemental to a visible metric.
  • Always pass label when the sparkline conveys information not otherwise available in surrounding text (e.g. a stat tile with no visible trend description).

This is an RSC-safe component — it ships no JavaScript to the browser.

data follows the Cartesian contract: homogeneous ascending x values, finite x/y values, and null for gaps. Development builds warn on invalid input; non-finite y values normalize to gaps.