Skip to content

Sparkline

Sparkline

A trend in 96×28 px. Pure SVG, no peer dependencies. Use it to garnish a stat, a row, or a header — switch to <Chart> when you need axes, legends, or interactivity.

Examples

<Sparkline data={[3, 5, 4, 6, 7, 9, 8, 10]} />
<Sparkline data={[10, 9, 8, 6, 5, 4, 3]} variant="area" />
<Sparkline data={[3, 6, 2, 7, 5, 8]} variant="bar" tone="brand" />

Inside StatCard

<StatCard label="Active sessions" value="1,284" delta="+4.2%">
<Sparkline data={trend} variant="area" tone="auto" width={140} height={36} />
</StatCard>

Custom color

tone accepts any CSS color string in addition to helixui scale refs:

<Sparkline data={[1, 2, 1.5, 2.4, 2.8]} tone="oklch(0.66 0.16 200)" />

Install: @helixui/core

import { Sparkline } from '@helixui/core'

status: stable · since: 0.7.0

Tags: mini-chart, inline, svg, trend

Anatomy

▁▂▃▅▆▇█▇▆▅▃▂▁ ← inline tiny chart

Layout

  • displayinline-block
  • widthcontent
  • heightcontent
  • intrinsicSize~80×24px (tunable)
  • stackabletrue
  • fullBleedfalse

Visual

A pure-SVG mini line/area chart with no axes or labels. Renders quickly inline next to a number. Tone (success/danger) tints the line per direction.

Props

NameTypeDefaultDescription
datanumber[]Series of y-values. Indexes are the x positions.
variant'line' | 'area' | 'bar'lineRender mode.
tone'brand' | 'success' | 'warning' | 'danger' | 'neutral' | 'auto' | stringautoColor. 'auto' picks success for upward, danger for downward, neutral for flat. Any CSS color is accepted.
strokeWidthnumber1.5Stroke width for line / area.
widthnumber96Render width in px.
heightnumber28Render height in px.
showLastbooleantrueDot at the last point. Defaults true for line/area, false for bar.
minnumberautoForce min y. Defaults auto-fit with 10% pad.
maxnumberautoForce max y. Defaults auto-fit with 10% pad.
smoothbooleantrueCatmull-Rom smoothed curve for line/area.
ariaLabelstringWhen set, the SVG gains role='img' and is announced.

Tokens used

color.bg.action.brand.default, color.bg.action.success.default, color.bg.action.warning.default, color.bg.action.danger.default, color.text.muted, radius.sm

Accessibility

Notes

  • Decorative by default — pass ariaLabel to surface a description.
  • Renders deterministically without animation; safe under prefers-reduced-motion.

Composes with

ComponentRelationNote
StatCardchildShown as the trend visualization in a StatCard.
ListchildPer-row trend in a list.
ChartalternativeUse Chart for full-size data viz.

Prompt examples

These are the AI prompt → JSX mappings used by the helixui prompt DSL and integrations like Cursor / Claude Code.

KPI trend line

“tiny green sparkline for revenue”

<Sparkline data={[1, 2, 3, 5, 4, 6, 8]} tone="success" />