Skip to content
↑↓ to navigate↵ to openesc to close

Menu

Sparkline

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 your package manager, or copy the source manually.

Run it in a project set up with shadcn-vue. The source is copied to components/beui and its dependencies are added to your package.json. Read the shadcn-vue guide

bunx --bun shadcn-vue@latest add @beui-vue/sparkline

Import the shared styles once in your application.

TSUsage
import Sparkline from '@/components/beui/charts/Sparkline.vue'
import '@/components/beui/styles.css'

API Reference

data
readonly (number | null)[]

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

Default—
labels?
readonly string[]

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

Default—
label
string

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

Default—
variant?
"line" | "area"
Defaultline
curve?
LineChartCurve
Defaultmonotone
color?
string

Any CSS color. Defaults to the current text color.

DefaultcurrentColor
height?
number

Height in px. Width follows the container.

Default32
strokeWidth?
number
Default1.5
showDelta?
boolean

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

Defaultfalse
invertDelta?
boolean

Color a fall green and a rise red, for metrics where lower is better.

Defaultfalse
interactive?
boolean

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

Defaultfalse
formatValue?
(value: number) => string
Default—
messages?
Partial<SparklineMessages>

Override any built-in string, including the shared `xyChart` ones. Named `messages` because `labels` already holds the sample labels.

Default—
class?
string
Default—

Updated