Blog / Development
Charts for Next.js and shadcn/ui projects: the copy-paste way
If your app is built on Next.js and shadcn/ui, you already work with components you own instead of packages you configure. Charts can work the same way. Here is the setup, step by step.
By Abdullah NomanNovember 30, 20263 min read

Short answer: put the chart components in components/charts, import their CSS once in app/layout.tsx, and use them inside any page. Interactive charts are client components, so the files start with 'use client'; your page can stay a server component and pass data down as props.
Where do the files go?
app/
layout.tsx ← import "@/components/charts/charts.css"
dashboard/page.tsx ← server component, fetches data
components/
charts/ ← the chart files (index.ts, core.tsx, …)
shadcn/ui projects already map @/ to the project root or src, so import { LineChart } from "@/components/charts" works as is.
Do charts work with server components?
Yes, with one rule: anything with hover, tooltips or animation runs in the browser, so the chart is a client component. Fetch on the server, then render the chart with the data:
// app/dashboard/page.tsx (server component)
import { LineChart } from "@/components/charts"
export default async function Page() {
const data = await getRevenue() // { labels, series }
return <LineChart data={data} area gradient />
}
Because the chart file starts with 'use client', Next.js handles the boundary for you.
How do charts follow your shadcn theme and dark mode?
Chart colours are CSS variables. Map them to your design tokens in globals.css:
.ch { --c1: var(--primary); --ink: var(--foreground); }
On older shadcn/ui setups that store bare HSL channels, wrap them: hsl(var(--primary)).
Dark mode in shadcn/ui and next-themes puts a dark class on <html>; the charts switch to their dark palette under that class automatically.
Does this work with Tailwind?
Yes. The charts do not need Tailwind, and Tailwind does not touch them. Size the chart with a wrapper such as <div className="w-full max-w-md">; the SVG scales to fit.
Where do the chart files come from?
Liniqo Charts gives you the folder: 62 named exports covering 67 chart types in 528 styles, in plain TypeScript that passes a strict type check. Download it once, then copy any chart's code from the gallery.
Questions
Can I use charts in Next.js server components?
Render them from a server component, but the chart itself is a client component because it handles hover and animation. Files that start with use client handle that automatically.
Does shadcn/ui have charts?
Yes, shadcn/ui charts are built on Recharts. Liniqo Charts is an alternative with no chart library underneath, using the same copy-paste model across 67 chart types.
How do I theme charts to match shadcn/ui?
Set the chart CSS variables, such as --c1 for the main series, to your shadcn tokens in globals.css.
Do the charts support dark mode in Next.js?
Yes. They switch when a dark class is on a parent element, which is how next-themes and shadcn/ui handle dark mode.


