---
title: "shadcn Chart Tutorial: Animated Chart in Next.js"
description: "Add an animated shadcn chart to a Next.js App Router page: install a free chart card with the shadcn CLI, feed it your data and change its colors."
url: https://www.mebius.design/guides/shadcn-chart-tutorial-nextjs
updated: 2026-11-22
---

# shadcn chart tutorial: an animated chart in Next.js

To add an animated shadcn chart to Next.js, install a chart from a shadcn registry with the CLI, render it from an App Router page and pass your data as props. mebius.design’s free Income Overview chart installs with one command and no account, and animates with anime.js.

8 min read · Updated Nov 22, 2026 · React + Tailwind

## What do you need to add a shadcn chart to Next.js?

From the Next.js docs and the mebius.design registry, checked on 22 Nov 2026.

A shadcn chart is source code that the shadcn CLI copies into your project, so the project needs Tailwind CSS v4 and a components.json; this tutorial uses Next.js with the App Router. The [Next.js installation docs](https://nextjs.org/docs/app/getting-started/installation) say `create-next-app --yes` sets up TypeScript, Tailwind CSS, ESLint, the App Router and Turbopack, with the @/\* import alias.

This tutorial uses the [Income Overview chart](https://www.mebius.design/freebies/charts/income-overview) from [mebius.design’s free shadcn charts](https://www.mebius.design/freebies/charts): a card with the year’s income, a badge with the change on last year, and one glossy bar per quarter against a target. The Income Overview chart is one of the open starter items, so its code is MIT and installs from its URL.

**The Income Overview chart at a glance**

- **Install**: `npx shadcn@latest add https://www.mebius.design/r/charts-income-overview.json`
- **License**: MIT, no account needed
- **Files**: 9 files, plus the chart theme in globals.css
- **npm packages**: animejs ^4.5.0, plus shadcn’s cn helper
- **Rendering**: A Client Component you render from a Server Component page
- **Size**: As wide as its container (418 px in Figma); 584 px tall with four quarters
- **Theme**: One light design, its colors scoped to the card
- **Checked on**: 22 Nov 2026, installed with shadcn 4.23.0

## How do you install a shadcn chart from the mebius.design registry?

Four steps, tested with shadcn 4.23.0 on 22 Nov 2026.

1. **Create the app**

   `npx create-next-app@latest my-dashboard --yes` gives you the App Router and Tailwind CSS v4.

2. **Set up shadcn**

   `npx shadcn@latest init` in the project folder writes components.json and the cn helper.

3. **Add the chart**

   `npx shadcn@latest add https://www.mebius.design/r/charts-income-overview.json` follows the chart’s registry dependencies, installs animejs and writes the files.

4. **Check what landed**

   components/income-overview-chart.tsx, three parts in components/ui, three hooks, two helpers in lib/, and the chart theme at the end of app/globals.css.

All 62 mebius.design charts install the same way: the open starter charts from their URL, the rest by name with a free account and a token from [Settings › Tokens](https://www.mebius.design/settings/tokens). AI editors can also install them over the shadcn or mebius MCP server ([setup guide](https://www.mebius.design/guides/install-shadcn-components-cli-mcp)).

## How do you use a shadcn chart in a Next.js App Router page?

A Server Component loads the data; the chart is a Client Component.

The Income Overview chart file starts with "use client", and a Server Component page can still render it: the page reads the numbers on the server and passes them down as props. The [Next.js "use client" docs](https://nextjs.org/docs/app/api-reference/directives/use-client) require those props to be serializable, so arrays and numbers cross over and functions don’t.

```tsx title="app/dashboard/page.tsx"
import { Suspense } from "react"

import { IncomeOverviewChart, type IncomeOverviewPeriod } from "@/components/income-overview-chart"

type IncomeRow = { quarter: number; amount: number }

// Swap this for a query to your database or API.
async function getQuarterlyIncome(year: number): Promise<IncomeRow[]> {
  const sample: Record<number, number[]> = {
    2025: [48_900, 55_120, 61_300, 70_450],
    2026: [61_240.5, 74_980, 88_310.25, 52_100],
  }
  return (sample[year] ?? []).map((amount, i) => ({ quarter: i + 1, amount }))
}

const sum = (rows: IncomeRow[]) => rows.reduce((total, row) => total + row.amount, 0)

async function IncomeOverview({ year }: { year: number }) {
  const [rows, lastYear] = await Promise.all([getQuarterlyIncome(year), getQuarterlyIncome(year - 1)])
  const periods: IncomeOverviewPeriod[] = rows.map((row) => ({
    id: `q${row.quarter}`,
    label: `Q${row.quarter}`,
    amount: row.amount,
  }))

  return (
    <IncomeOverviewChart
      className="max-w-[418px]"
      title={`Income ${year}`}
      periods={periods}
      target={100_000}
      change={sum(rows) - sum(lastYear)}
      changeLabel={`vs ${year - 1}`}
    />
  )
}

export default function DashboardPage() {
  return (
    <main className="p-6">
      <Suspense fallback={<div className="h-[584px] w-full max-w-[418px] rounded-3xl bg-neutral-100" />}>
        <IncomeOverview year={2026} />
      </Suspense>
    </main>
  )
}
```

The `<Suspense>` boundary lets the rest of the page show while the query runs. The [Next.js data fetching docs](https://nextjs.org/docs/app/getting-started/fetching-data) offer that, or a "use cache" directive on the data function, for data read at request time.

## How do you feed the Income Overview chart your own data?

The props, from the chart’s own docs in the mebius.design registry.

- `periods`: one bar per row, top to bottom, each { id, label, amount }. Quarters, months or weeks all work.
- `target`: each row’s target. The axis runs to it, or past it when a row goes over, with six round labels.
- `total`: the big number, the sum of periods by default.
- `change` and `changeLabel`: the badge, green when up and red when down; null hides it.
- `locale` and `currency`: how the total, the badge, the tag and the axis ("20K") are formatted.
- `index` and `onIndexChange`: the pinned row. Hover and focus preview a row without pinning it.
- `onInsightClick` and `onMoreClick`: the See insight and ⋯ buttons.

Callbacks are functions, so they live in a small Client Component of your own, which the page renders with the rows from its query:

```tsx title="components/income-card.tsx"
"use client"

import * as React from "react"

import { IncomeOverviewChart, type IncomeOverviewPeriod } from "@/components/income-overview-chart"

export function IncomeCard({ periods, reportUrl }: { periods: IncomeOverviewPeriod[]; reportUrl: string }) {
  const [quarter, setQuarter] = React.useState<number | null>(null)
  const pinned = quarter === null ? undefined : periods[quarter]

  return (
    <section className="flex max-w-[418px] flex-col gap-3">
      <IncomeOverviewChart
        periods={periods}
        index={quarter}
        onIndexChange={(next) => setQuarter(next)}
        onInsightClick={() => window.location.assign(reportUrl)}
      />
      <p className="text-sm text-neutral-600">
        {pinned ? `${pinned.label} is pinned. Click it again to let go.` : "Click a quarter to pin its amount."}
      </p>
    </section>
  )
}
```

## How does the mebius.design chart animation work?

Read from the chart’s source: anime.js v4, no Recharts.

Every mebius.design chart draws its own HTML or SVG and animates it with anime.js. The hook in hooks/use-chart-motion.ts builds the entrance as one paused anime.js timeline, renders its first frame before the browser paints, and plays it once a quarter of the card is in view. In the Income Overview chart:

- The total counts up from zero over 1.4 seconds, and the badge pops in with its amount counting.
- The divider opens, then the bars grow from the axis’ start, 90 ms apart and 1.1 seconds each, with a light band sweeping across each bar as it settles.
- The axis labels and the See insight button fade in last.

After the entrance, the Income Overview chart animates changes: new data grows or shrinks each bar from its current width, and the total and the value tag count from the old number to the new one. Pointing at a quarter dims the other bars and slides the tag over.

With prefers-reduced-motion set to reduce, nothing animates. The server renders the finished chart, so the HTML shows the real figures before any JavaScript runs.

shadcn/ui’s chart component leaves motion to Recharts, whose [Bar](https://recharts.github.io/en-US/api/Bar/) takes isAnimationActive (default "auto") and animationDuration (default 400 ms), checked on 22 Nov 2026.

## How do you change the colors of a mebius.design chart?

Theme variables scoped to the card, or the classes in the file.

The chart theme that the install adds to globals.css sets the Keitoto palette (surfaces, text, and blue, green, orange, purple, yellow and error scales) on every element with data-charts, and each mebius.design chart’s card carries that attribute. Your shadcn theme doesn’t reach the card, and the card doesn’t change your app’s colors.

The Income Overview bars read three of those variables: --primary-blue-600, --primary-blue-400 and --primary-blue-200. Extra props go to the card’s div, so a style prop recolors one card:

```tsx title="components/violet-income-card.tsx"
import type { CSSProperties } from "react"

import { IncomeOverviewChart } from "@/components/income-overview-chart"

// The bars' gradient, from the chart theme: set on the card, it recolors this card only.
const violet = {
  "--primary-blue-600": "#6d28d9",
  "--primary-blue-400": "#8b5cf6",
  "--primary-blue-200": "#c4b5fd",
} as CSSProperties

export function VioletIncomeCard() {
  return <IncomeOverviewChart className="max-w-[418px]" style={violet} />
}
```

To change the blue of every mebius.design chart card at once, set the same variables on \[data-charts\] below the chart theme:

```css title="app/globals.css"
/* after the chart theme the install added */
[data-charts] {
  --primary-blue-600: #6d28d9;
  --primary-blue-400: #8b5cf6;
  --primary-blue-200: #c4b5fd;
}
```

- The focus ring reads --primary-blue-500. The ring of a pinned quarter is written as rgb(9 125 246 / 0.5) in components/income-overview-chart.tsx, so change that class too.
- The code is yours: edit the Tailwind classes in the file like any shadcn component.
- Some cards take colors as data. The [Expenses chart](https://www.mebius.design/freebies/charts/expenses) gives each category orange, green, yellow, blue or purple.
- The charts use SF Pro Rounded, which can’t be bundled: Apple devices render it through ui-rounded and other browsers fall back to the system font. Set --font-charts-rounded to use another font.

## How is a mebius.design chart different from shadcn/ui’s chart component?

shadcn/ui’s docs checked on 22 Nov 2026.

shadcn/ui’s [chart component](https://ui.shadcn.com/docs/components/chart) is a layer on Recharts v3. `npx shadcn@latest add chart` adds ChartContainer, a ChartConfig type for labels and colors, and tooltip and legend parts; you write the Recharts chart yourself. Its colors are CSS variables such as --chart-1, set under :root and .dark, so shadcn/ui charts follow your theme and dark mode. It is the better pick for standard charts in your own look.

mebius.design’s charts are finished dashboard cards instead: title, figures and controls included, drawn without Recharts and matched to a Figma file. Both kinds can share a page, because each mebius card keeps its theme to itself. More options are compared in [Best shadcn charts](https://www.mebius.design/guides/best-shadcn-charts).

## FAQ

Answers to what people ask most.

### Is the Income Overview chart free for commercial use?

Yes. Its code is MIT: the Income Overview chart is one of mebius.design’s 20 open starter items, which install from their URL with no account. The other charts and the Figma file of all 62 need a free account; they are free to use in your projects under the [mebius.design license](https://www.mebius.design/license), which doesn’t allow redistributing them.

### Does a shadcn chart work with Next.js Server Components?

Yes. The mebius.design charts are Client Components, so a Server Component page can render them and pass data such as arrays and numbers. Functions like onInsightClick need a Client Component wrapper, because props sent from the server must be serializable.

### Do mebius.design charts support dark mode?

No. Each mebius.design chart card has one light design, with its colors scoped to the card, so it stays white on a dark page. shadcn/ui’s own charts follow your .dark theme.

### Can an AI editor install the chart for me?

Yes. Claude Code or Cursor can run the shadcn add command, or use the mebius MCP server, which returns each chart’s source and usage docs with a free account. Setup is in [shadcn MCP: install UI components](https://www.mebius.design/guides/install-shadcn-components-cli-mcp).

## Related

Item pages, kits and guides this guide uses.

- [Free charts](https://www.mebius.design/freebies/charts): 62 animated React + Tailwind chart cards with their Figma file, installed with the shadcn CLI.
- [Income Overview Chart](https://www.mebius.design/freebies/charts/income-overview): The open (MIT) chart from this tutorial: quarterly income against a target.
- [Best shadcn charts](https://www.mebius.design/guides/best-shadcn-charts): shadcn/ui, shadcn.io, Tremor, Recharts, shadcn-echarts and mebius.design compared.
