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 ofhsl(var(--chart-1)). ChartContainertakes aconfigprop and needs a height,min-h-*oraspect-*class to size itself (the docs recommendmin-h-[VALUE], though one axis example uses a fixedh-[200px]).ChartConfigis 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). ChartTooltipandChartLegendcome with content components; theaccessibilityLayerprop 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