Sparkline

A compact inline trend for stat cards and tables, with a change badge and optional readout.

Preview

Last 30 days, demo data
Revenue$52.2K
Active users1,939
Error rate1.56%

Interactive: hover, drag or use the arrow keys

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/sparkline

API Reference

data
readonly (number | null)[]

Samples in display order. Missing or non-finite values leave a gap.

—
labels?
readonly string[]

Optional sample labels, such as dates, used by the interactive readout.

—
label
string

Accessible name, such as "Revenue, last 30 days".

—
variant?
"area" | "line"
line
curve?
"step" | "monotone" | "linear"
monotone
color?
string

Any CSS color. Defaults to the current text color.

currentColor
height?
number

Height in px. Width follows the container.

32
strokeWidth?
number
1.5
showDelta?
boolean

Show the change from the first to the last sample as a badge.

false
invertDelta?
boolean

Color a fall green and a rise red, for metrics where lower is better, such as error rate.

false
interactive?
boolean

Hover, drag or arrow keys to read individual samples. Adds one tab stop.

false
formatValue?
((value: number) => string)
(value) => number.format(value)
className?
string
—

Updated