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';Playground
Props
<Sparkline values={[42, 48, 45, 56, 61, 68]} color={2} area label="Up 62% over six months" />Examples
In a stat
States
defaultloading
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| valuesrequired | number[] | — | The points, oldest first. |
| label | string | — | Accessible summary, such as "Revenue, last 12 weeks, up 8%". Without it the sparkline is decorative. |
| color | 1 | 'neutral' | 'warning' | 'danger' | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 'good' | 1 | Palette colour, 1–8. |
| area | boolean | false | Fill the area under the line. |
| emptyState | React.ReactNode | — | Shown when values is empty. No default: an empty sparkline stays an empty box. |
| errorState | React.ReactNode | — | Shown in place of the data when a load failed, for example an ErrorState with a retry action. Wins over loading and empty. |
| interactive | boolean | — | A crosshair and tooltip that follow the pointer, and arrow-key navigation between points. |
| loading | boolean | — | 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
Web only
Sparkline has no @nexub/react-native twin. On phones, follow the platform pattern instead, or compose it from the native components listed on the React Native page.