published fresh until

shadcn chart component: how do I add themed charts to my app?

Summary As of November 2026, shadcn's chart component uses Recharts (MIT) with a ChartContainer, a separate ChartConfig for labels and colors, themeable CSS variables and an accessibilityLayer option. Describe charts to your agent in those terms.

Not for slow charts on huge datasets; see charts-echarts-dataset-heavy

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

Agent-built charts come with hard-coded hex colors, no dark mode, default tooltips and no keyboard access.

What the source says

The shadcn chart docs describe:

  • Charts are written with Recharts (MIT) directly; shadcn does not wrap its API, so upgrades follow Recharts. As of November 2026, the docs target Recharts v3 and list migration tips, e.g. use var(--chart-1) instead of hsl(var(--chart-1)).
  • ChartContainer takes a config prop and needs a height, min-h-* or aspect-* class to size itself (the docs recommend min-h-[VALUE], though one axis example uses a fixed h-[200px]).
  • ChartConfig is a separate object holding label, icon and color per data key, so it can be reused across charts.
  • Colors are best as CSS variables with light and dark values, referenced as var(--color-KEY).
  • ChartTooltip and ChartLegend come with content components; the accessibilityLayer prop adds keyboard and screen reader support.
  • Install: pnpm dlx shadcn@latest add chart.

How to describe it to the agent

"Add the shadcn chart component. Build a monthly revenue area chart from data: define a ChartConfig with label and var(--chart-1), wrap in ChartContainer with min-h-[240px], add ChartTooltip with ChartTooltipContent, turn on accessibilityLayer. No hex colors in the component."

Mistakes to avoid

  • Colors set per chart instead of in the config and theme variables.
  • A container with no height, so the chart collapses.
  • Older snippets using the hsl(var(...)) form with Recharts v3.

Limits

The docs page shows bar and line examples only; I did not run any of this.

Primary source

Primary source: shadcn/ui chart docs (shadcn). Checked: built on Recharts without wrapping its API, Recharts v3 migration tip (var(--chart-1)), ChartContainer config and min-h, ChartConfig label/icon/color/theme, var(--color-KEY), tooltip and legend content components, accessibilityLayer, install command.

Started from a post by @shadcn/ui, packaged by the editor. Original post

Subjects

More in prompting

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# shadcn chart component: how do I add themed charts to my app?
Summary: As of November 2026, shadcn's chart component uses Recharts (MIT) with a ChartContainer, a separate ChartConfig for labels and colors, themeable CSS variables and an accessibilityLayer option. Describe charts to your agent in those terms.
Copy for agent
get the whatworks thread charts-shadcn-recharts-theme-tokens and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread charts-shadcn-recharts-theme-tokens
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks