ComponentsGraphics

Sparkline

Compact SVG line chart from an array of numbers, with a currentColor stroke and fading area fill. Missing values break the line, one point draws a dot, and an aria-label exposes it as an image.

Open the preview in a new tab

The source comes with full access.

One payment of $149 opens the source right here and lets the CLI install every paid component, with lifetime updates.

Installation

pnpm dlx shadcn add @01orbital/sparkline
npx shadcn add @01orbital/sparkline
yarn shadcn add @01orbital/sparkline
bunx --bun shadcn add @01orbital/sparkline

Part of the 01orbital library. With a license, put ORBITAL_TOKEN in .env.local and the same command installs it (licensed install, pricing).

It lands at components/graphics/sparkline.tsx, as source you own and edit.

Usage

import { Sparkline } from "@/components/graphics/sparkline"

export default function SparklineDemo() {
  const data = [8, 10, 9, 13, 11, 16, 14, 18, 15, 21, 19, 24]
  return (
    <div className="grid text-primary">
      <Sparkline
        data={data}
        width={260}
        height={80}
        aria-label="Signups rising over 12 weeks, from 8 to 24"
        className="w-72"
      />
    </div>
  )
}

API reference

Prop

Type

It also accepts the HTML attributes of the element it renders.

Dependencies

npm: cn. The CLI installs them for you.

No other registry pieces.

On this page