Dashral Pro is on the wayGet 30% off at launch

Dashral

Sparkline

A tiny line, area or bar chart without axes, for a trend next to a number or in a table cell.

$ pnpm dlx shadcn@latest add https://dashral.com/r/sparkline.json
line
area
bar

Installation

$ pnpm dlx shadcn@latest add https://dashral.com/r/sparkline.json

Adds the component, the components it builds on, its npm packages and the theme tokens it uses. Using Dashral often? Add the registry to components.json once:

components.json
{
  "registries": {
    "@dashral": "https://dashral.com/r/{name}.json"
  }
}

Then add components by name:

$ pnpm dlx shadcn@latest add @dashral/sparkline

Usage

example.tsx
import { Sparkline } from "@/components/dashral/sparkline"

<Sparkline data={[12, 18, 15, 22, 28, 26, 34]} variant="area" showLast aria-label="Sign-ups rising from 12 to 34 this week" />

Examples

In a table

Color it with a text color — green when rising, red when falling.

PageViews8 weeks
/pricing8,420
/docs/install5,310
/blog/launch3,975

Live watchlist

Each line shifts as a new price arrives, and the price flashes the way it moved.

Watchlist

Live
  • ACMEAcme Corp$194.00+6.59%
  • NUSAPT Nusantara$57.00−10.94%
  • GLBXGlobex$45.70+11.46%
  • INITInitech$126.00+5.00%

API reference

Sparkline

Also takes every prop of <div>(opens in a new tab).

PropTypeDefault
datanumber[]

Oldest first. Required.

—
variant"line" | "area" | "bar""line"
showLastboolean

A dot on the latest value.

false
min / maxnumber

Scale limits; min={0} starts at zero.

the data's
aria-labelstring

Say what the trend means.

"Trend from … to …"
classNamestring

Size and color (a text color).

"h-8 w-full text-primary"

Accessibility

  • role="img" with your label: describe the trend in words (“Rising from $1.2K to $2.4K”).

Motion

  • The line draws itself (bars grow) when it first shows; instant with reduced motion.