Controls

Sparkline

Preview
Reduced motion

Simulates prefers-reduced-motion for the demo. Off follows your system setting.

Keyboard stepping

Steps focus through the demo with ] and [. Tab, arrows, and Escape stay native so the component behaves as shipped.

Sparkline
  • Signups

    1,284

    Signups over twelve months
    pointSignups over twelve months
    Jan42
    Feb51
    Mar48
    Apr62
    May58
    Jun71
    Jul69
    Aug84
    Sep92
    Oct88
    Nov104
    Dec118
  • Active users

    8,920

    Active users over twelve months
    pointActive users over twelve months
    Jan610
    Feb640
    Mar655
    Apr630
    May700
    Jun720
    Jul760
    Aug745
    Sep800
    Oct830
    Nov870
    Dec892
  • Refunds

    37

    Refunds over twelve months
    pointRefunds over twelve months
    Jan9
    Feb7
    Mar8
    Apr6
    May7
    Jun5
    Jul6
    Aug4
    Sep5
    Oct4
    Nov3
    Dec4

Sparkline

A tiny line with no axes that shows a trend at a glance.

Installation

npx shadcn@latest add ikislay/pixel-ui/sparkline

How to use

import { Sparkline } from "@/components/ui/sparkline"
export function Demo() {
return (
<div className="w-40">
<Sparkline label="Signups this week" data={[12, 18, 15, 22, 27, 24, 31]} />
</div>
)
}

Source Code

// Loading…

Props

Options you can pass to customize this component.

Prop
Type
Description
data*
number[]

The values, oldest first.

labels
string[]

A label for each value, shown in the tooltip. Without it the tooltip shows only the value.

label*
string

Names the chart for screen readers and captions its data table.

color
string

Any CSS color for the line and its fill.

height
number

Height in pixels. The width fills the parent.

format
(value: number) => string

Formats values wherever the chart shows them. Defaults to short numbers like 12.4K.

className
string

Merged onto the root element.