Skip to content
nexubDesign System
v11.9.0

Components · Data Display

Sparkline

BetaAdded v3.2.0

A tiny trend line with no axes, for stat cards and table cells.

import { Sparkline } from '@nexub/react';
View as Markdown

Playground

Props

TSX
<Sparkline values={[42, 48, 45, 56, 61, 68]} color={2} area label="Up 62% over six months" />

Examples

In a stat

Monthly revenue

$68,420

States

  • default
  • loading

Props

Props
PropTypeDefaultDescription
valuesrequirednumber[]—The points, oldest first.
labelstring—Accessible summary, such as "Revenue, last 12 weeks, up 8%". Without it the sparkline is decorative.
color1 | 'neutral' | 'warning' | 'danger' | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 'good'1Palette colour, 1–8.
areabooleanfalseFill the area under the line.
emptyStateReact.ReactNode—Shown when values is empty. No default: an empty sparkline stays an empty box.
errorStateReact.ReactNode—Shown in place of the data when a load failed, for example an ErrorState with a retry action. Wins over loading and empty.
interactiveboolean—A crosshair and tooltip that follow the pointer, and arrow-key navigation between points.
loadingboolean—Shows a skeleton in place of the data and sets aria-busy.
onPointClick((point: ChartPoint<number>) => void)—Click, tap, or Enter/Space on a point. Turns interactive on unless it is set to false.

Accessibility

Screen reader

  • The chart is a `figure` named by `title`. The drawing is hidden from assistive tech; a visually hidden table carries every value.

  • Colour is never the only cue: the legend and table name each series. Past six series, label directly or group the rest as "Other".

On iOS & Android