Skip to Content
zjkm-ui
Components

Chart Lines

Chart lines that draw themselves.

Props
1.5s
0.15s
<ChartLines>
  <LineChart />
</ChartLines>

Installation

npx shadcn@latest add https://ui.zjkm.tech/r/chart-lines.json
import { 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

PropTypeDefaultDescription
childrenReactNodeYour SVG chart.
selectorstring"path"CSS selector for the elements that draw in.
durationnumber1.5Seconds per line.
staggernumber0.15Seconds between one line starting and the next.
classNamestringClasses for the wrapper.

With reduced motion, the chart shows complete.

On this page