Skip to main content

Sparkline

A lightweight SVG sparkline component for visualizing data trends. Supports line, area, and bar variants with gradient and glow effects.

Installation

$ npx shadcn@latest add @orecus/sparkline
Dependencies:
motion
Registry:
skeleton@orecus/color-utils@orecus/use-reduced-motion

Component

Lightweight SVG charts for displaying trends in compact spaces. Three types available: line, area, and bar.

Line Chart
Area Chart
Bar Chart
Sharp Line (No Curve)

Multi-series

2 Series (Line)
2 Series (Area)
3 Series (Line)
3 Series (Area)

Props

PropTypeDefaultDescription
data*number[] | SparklineSeries[]Array of data points (or multi-series objects with name, data, and optional color)
type'line' | 'area' | 'bar''line'Visual style of the sparkline
colorThemeColor'primary'Theme color for the chart
widthnumber100Width in pixels
heightnumber40Height in pixels
strokeWidthnumber2Line thickness in pixels (line/area types)
curvedbooleantrueWhether to use smooth curves (line/area types)
showEndDotbooleantrueWhether to highlight the last data point
showFillbooleantrueWhether to fill the area under the line (area type)
barGapnumber2Gap between bars in pixels (bar type)
barRadiusnumber2Corner radius for bars in pixels (bar type)
variant'default' | 'gradient''gradient'Color style - 'gradient' uses soft SVG gradients
glowbooleantrueAdd colored glow/blur effect (works best with gradient variant)
fullWidthbooleanfalseWhether to fill the available width of the container
showTooltipbooleanfalseShow tooltip with data value on hover
valueFormatter(value: number) => stringFormatter for tooltip values
animatedbooleanfalseWhether to animate the sparkline on mount
loadingbooleanfalseShows skeleton loading state
classNamestringAdditional CSS classes
referenceLinesSparklineReferenceLine[]Horizontal reference lines (y-values only) rendered on the sparkline