ValyroUI Русская версия

Sparkline

Tiny inline charts. Free, MIT · Charts and analytics › Trends

Tiny inline chart without axes, colored by trend.

Installation

npx valyro-cli@latest add sparkline
npx shadcn@latest add https://valyro.xyz/r/sparkline.json
npm install valyro-ui

import 'valyro-ui/styles.css';
import { Sparkline } from 'valyro-ui';

Props

PropTypeDefault
data *(number | null)[]Values in order; missing (null / NaN) values leave a gap.
variant'line' | 'area' | 'bar''line'line: trend line. area: line over a gradient fill. bar: one bar per value, growing from zero.
widthnumber80Default 80.
heightnumber24Default 24.
colorstringAny CSS color. Default: green when the last value is above the first, red when below.
higherIsBetterbooleantrueFalse for metrics where a decrease is good (latency, bounce rate): swaps the trend colors. Default true.
showDotbooleanfalseDot on the last point (line and area).
curve'linear' | 'monotone''monotone'monotone smooths the line without overshooting the data; linear joins points straight. Ignored for bars.
ariaLabelstringAccessible name. Without it the sparkline is treated as decorative.

Related components

Previous: Scatter Chart · Next: Confidence Band Chart · All Charts and analytics