Skip to content
ChartslibraryUI
Get Pro

Add to an existing app

Your app doesn't need to be a shadcn/ui project, use Tailwind, or change its styles. The charts are plain React files with one stylesheet of their own (scoped to .clui), so they sit next to whatever you already have.

Don't run npx shadcn init in an existing app. It's meant for new shadcn projects: it rewrites your global CSS, adds Tailwind and its theme variables, and creates lib/utils. You only need a components.json the CLI can read.

1. Add a minimal components.json

Create it at the root of the project (next to package.json):

{
  "$schema": "https://ui.shadcn.com/schema.json",
  "style": "new-york",
  "rsc": true,
  "tsx": true,
  "tailwind": { "config": "", "css": "", "baseColor": "neutral", "cssVariables": true },
  "aliases": { "components": "@/components", "utils": "@/lib/utils" },
  "registries": { "@chartslibraryui": "https://chartslibraryui.com/r/{name}.json" }
}
  • The tailwind block must be there for the CLI to accept the file, but with empty paths it changes nothing: our charts bring no Tailwind classes and no CSS variables to merge.
  • aliases.components is where files go: @/components puts charts in components/charts/ (or src/components/charts/ when @/ points to src/). Match your tsconfig.json paths. No @/ alias? Use a relative folder through the CLI's --path, or the chartslibraryui CLI below.
  • rsc keeps the "use client" line at the top of each chart. Leave it true, even in Vite: the line is harmless there.
  • For Pro, replace the registries entry with the one that sends your key (see Pro charts).

2. Install a chart

pnpm dlx shadcn@latest add @chartslibraryui/line-chart

This writes components/charts/line-chart.tsx and components/charts/core/*, and nothing else. Check with --dry-run first if you like.

3. Import the stylesheet once

In your root layout or entry file:

import "@/components/charts/core/charts.css"; // or a relative path

All its rules are scoped to .clui, and its colours are CSS variables you can override in your own CSS (see Theming). It doesn't reset or restyle anything outside the charts.

4. Use it

import { LineChart } from "@/components/charts/line-chart";

<LineChart title="Revenue is ahead of plan" data={rows} x="month" series={["revenue", "plan"]} format="currency" />

For a locale or currency other than en-US/USD, wrap the app once in <ChartsProvider locale currency> (see Number formatting).

Without components.json

The chartslibraryui CLI needs no config file at all:

pnpm dlx chartslibraryui add line-chart bar-chart --dir src/components/charts

Or copy the files by hand from each chart page's Source section (see Installation).

Checklist

  • React 18 or 19. TypeScript recommended (the files are .tsx); strict mode is fine.
  • No new npm dependencies.
  • Next.js App Router: render charts from server components freely; they're client components already.
  • When you update later, see Upgrading: updates replace the chart files, so keep your changes outside components/charts/.

Sign in to ChartslibraryUI

New here? The same step creates your account.

Continue with Google
or

No password needed. Bought Pro? Use the email you paid with and your license is there. By signing in you agree to the Terms and Privacy policy.