Line chart
An area chart you scrub with a pointer or a finger. The crosshair snaps from day to day, the figure above rolls to each value, and the rest of the line dims behind you.
npx shadcn@latest add @uimaxxer/line-chartPasskeysSpend
Spend
Revenue, 1 to 29 Nov
$39,741
+14.9% vs 4 Oct to 1 Nov
1 Nov29 Nov
1 to 29 Nov4 Oct to 1 Nov
Line chart is a Pro component
The demo and the docs are free. The source comes with Pro, through this page, the shadcn CLI and the MCP.
Usage
import { LineChart } from "@/components/ui/line-chart"
<LineChart
title="Revenue, 1 to 29 Nov"
compareLabel="4 Oct to 1 Nov"
data={days}
format={{ style: "currency", currency: "USD", maximumFractionDigits: 0 }}
/>Props
| Prop | Type | Default | What it does |
|---|---|---|---|
| data | LinePoint[] | { label, tick?, value, compare?, compareName? }. compare draws the second, quieter line; compareName labels that point. | |
| title | string | What the chart measures. Shown above the figure when nothing is scrubbed. | |
| total | number | The resting figure. Defaults to the sum of the values. | |
| compareTotal | number | The comparison total. Defaults to the sum of the compare values. | |
| compareLabel | string | Names the comparison, as in vs October. Also the legend. | |
| seriesLabel | string | "This period" | Legend name for the main line. |
| format | Intl.NumberFormatOptions | How every figure is written. Pass a stable object. | |
| height | number | 200 | Plot height in px. The width follows the container. |
| size | "md" | "lg" | "md" | lg sets a 56px figure and heavier marks, for a feature moment. |
Keyboard
- ← →
- Previous or next point
- Home / End
- First or last point
- Esc
- Back to the total
Accessibility
- The plot is a role=slider over the points; aria-valuetext reads the date and the value.
- Hover scrubs with a mouse; on touch, press and slide. Vertical swipes still scroll the page.
- One accent and ink, no gridlines; the comparison is told apart by weight and a legend, not by colour alone.
- Reduced motion skips the draw-in and snaps the crosshair.