Skip to content
ZikZuk UI

Sparkline

Stripe Sparkline

A trend beside a figure or inside a table cell: plain SVG, no axes, no dependencies. Teal by default; tone="trend" turns it green going up and red going down. Takes numbers, or objects with y naming the value field, and width="fill" stretches it to its cell.

pnpm add @zikzuk/ui
import { Sparkline } from "@zikzuk/ui";

Tones and area

brand (default)
neutral
trend, going up
trend, area

In a table

Objects with y, filling the cell.

BranchLast 4 days
Andheri
Bandra

When to use

  • Beside a value in a StatGroup.
  • A column of trends in a table.

Not for

  • Anything someone must read exact values from — use a chart.

Props

PropTypeDescription
data(number | T)[]Numbers, or objects read through y.
ykeyof T | (d: T) => numberThe value field of each object.
widthnumber | "fill"
Default 64
fill stretches to the container.
heightnumber
Default 20
In pixels.
tone"brand" | "neutral" | "done" | "failed" | "trend"
Default "brand"
trend: green up, red down.
variant"line" | "area"
Default "line"
area adds a soft fill.
strokeWidthnumber
Default 1.5
Line thickness; kept when stretched.
labelstringScreen-reader text; without it the line is decorative.
classNamestringExtra classes on the outer element.