Components
Chart Lines
Chart lines that draw themselves.
<ChartLines>
<LineChart />
</ChartLines>Installation
npx shadcn@latest add https://ui.zjkm.tech/r/chart-lines.jsonimport { ChartLines } from "@/components/chart-lines"Using JavaScript? Set tsx: false in components.json and the CLI converts it.
New to shadcn? Run npx shadcn@latest init first. The CLI needs components.json and the @/ import alias.
Usage
Wrap any SVG chart, your own or one from a chart library. Once it scrolls into view, its lines draw themselves in, one after another. Afterwards the chart is exactly as it was: Chart Lines only borrows the dash settings while it plays.
import { ChartLines } from "@/components/chart-lines";
export function Signups() {
return (
<ChartLines selector=".recharts-line-curve">
<SignupsChart />
</ChartLines>
);
}By default every <path> draws in. If your chart has paths that shouldn't, such as filled areas or grid lines, pass a selector that matches only the lines.
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children | ReactNode | Your SVG chart. | |
selector | string | "path" | CSS selector for the elements that draw in. |
duration | number | 1.5 | Seconds per line. |
stagger | number | 0.15 | Seconds between one line starting and the next. |
className | string | Classes for the wrapper. |
With reduced motion, the chart shows complete.