Sparkline
A small, inline trend chart with no axes or labels.
Import
import { Sparkline } from '@matix/charts/sparkline';Usage
Area variant
API Reference
| Prop | Type | Default | Description |
|---|---|---|---|
data | ChartPoint[] | — | Single series. y: null renders as a gap. |
width | number | 120 | Fixed px width — inline element, not responsive. |
height | number | 32 | Fixed px height. |
variant | 'line' | 'area' | 'line' | 'area' adds a soft fill under the line. |
curve | 'straight' | 'curved' | 'curved' | Line interpolation. |
animate | boolean | false | CSS draw-in on mount. Usually left off for spark in a stat tile. |
colorIndex | number | 0 | Palette slot when composing multiple sparklines. |
label | string | — | Accessible description. Required for a11y — omitting renders aria-hidden. |
sx | StyleXStyles | — | StyleX style override |
Accessibility
- Renders an
<svg>withrole="img"andaria-label={label}whenlabelis provided. - Without
label, the<svg>rendersaria-hidden="true"— there is no default label that could lie about what the trend shows. descriptionadds a richer hidden summary.aria-describedbylinks consumer-owned text, andaccessibleDatasupplies 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
labelwhen 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.