Skip to content
peakcharts

Installation

Install the package, import the stylesheet once, then render a chart.

Install

$ npm install peakcharts

React, React DOM and Motion are peer dependencies. npm 7 and newer installs them when compatible versions are missing. peakcharts requires React 18 or newer.

Render a chart

Import the stylesheet once, for example in your root layout. Then render any chart.

Revenue.tsx
import { BarChart } from 'peakcharts';
import 'peakcharts/styles.css';

export default function Revenue() {
  return (
    <BarChart
      title="Revenue by month"
      data={[
        { label: 'Jan', value: 32 },
        { label: 'Feb', value: 46 },
        { label: 'Mar', value: 63 },
      ]}
    />
  );
}
Revenue by month
Revenue by monthClick a mark to pin its value; click it again to release. Keyboard: Enter or Space to pin, Escape to release. Data table below.015.831.547.363JanFebMarJan: 32Feb: 46Mar: 63
Click a mark to pin its value
View data
Revenue by month
LabelValue
Jan32
Feb46
Mar63

Use it with Next.js

The App Router works as is. The bundle ships with "use client", so you can import charts from server components or your root layout. Charts do not touch window or document, so they render on the server too.

app/layout.tsx
import 'peakcharts/styles.css';

export default function RootLayout({ children }) {
  return (
    <html lang="en">
      <body>{children}</body>
    </html>
  );
}

Charts are plain SVG styled with CSS variables, so any evergreen browser works. If the chart looks unstyled, see Troubleshooting.