GitHubGitHub
← All widgets
Data display / widget

Sparkline

Tiny SVG trend line with missing-value handling, area or line modes, and accessible summaries.

LineAreaPositiveNegativeMissing
Area · positive
Line · negative
<Sparkline data={[12, 14, null, 18, 17]} />

Installation

pnpm add @chanrg/4ui

Import the stylesheet once, at the root of your app:

import '@chanrg/4ui/styles.css';

Usage

import { Sparkline } from '@chanrg/4ui';<Sparkline data={[12, 14, null, 18, 17]} />

API reference

Props

PropTypeDefaultDescription
dataArray<number | null>[]Normalized trend values.
variantline | areaareaFill treatment.

CSS variables

VariableDescription
--4ui-surfacePrimary component surface.
--4ui-textPrimary foreground color.
--4ui-borderDefault control and panel border.

Accessibility

  • The SVG exposes minimum and maximum values in its accessible name.

Dependencies

No runtime component dependencies.