Controls

Line Chart

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.

Line Chart
  • Visitors
  • Returning

Visitors by month
monthVisitorsReturning
Jan1.8K920
Feb2.1K1K
Mar2K1.1K
Apr2.6K1.2K
May3K1.4K
Jun2.9K1.5K
Jul3.3K1.5K
Aug3.6K1.7K
Sep3.4K1.8K
Oct4K1.9K
Nov4.3K2.2K
Dec4.6K2.4K

Line Chart

A smooth line chart for one or more series over time.

Installation

npx shadcn@latest add ikislay/pixel-ui/line-chart

How to use

import { LineChart } from "@/components/ui/line-chart"
const data = [
{ month: "Jan", visits: 1200 },
{ month: "Feb", visits: 1900 },
{ month: "Mar", visits: 1600 },
]
export function Demo() {
return (
<LineChart
label="Visits by month"
data={data}
index="month"
series={[{ key: "visits", label: "Visits" }]}

Source Code

// Loading…

Props

Options you can pass to customize this component.

Prop
Type
Description
data*
Record<string, string | number>[]

One object per point along the x axis.

index*
string

The key in each object that labels the x axis.

series*
{ key: string; label?: string; color?: string }[]

The keys to plot. Colors follow the chart palette in order unless you set one.

label*
string

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

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.

curve
smoothlinear

Smooth bends through every point without overshooting it; linear joins them with straight lines.

className
string

Merged onto the root element.