Skip to content
Launch price: Pro is $79 once →
ChartslibraryUI
By Killian Helf · Updated 2026-11-29

Build a React Dashboard with Claude Code or Cursor (Charts That Stay Consistent)

Coding agents are good at wiring data to components and bad at design consistency. Ask Claude Code or Cursor for "a revenue dashboard" and you get working charts, each styled a little differently, with choices you'd never make on purpose: a dual axis, bars that don't start at zero, a forecast drawn like actuals. This tutorial sets up a project so the agent picks from ready-made chart components instead, and shows the prompts that work.

It assumes a React or Next.js project with the shadcn CLI available (components.json exists). It works the same in Claude Code, Cursor, Windsurf, Codex and other agents that can run commands.

1. Give the agent a chart registry

Add the ChartslibraryUI namespace to components.json once:

{
  "registries": {
    "@chartslibraryui": "https://chartslibraryui.com/r/{name}.json"
  }
}

Now the agent (and you) can install any free chart by name:

npx shadcn@latest add @chartslibraryui/line-chart

Each chart lands in components/charts/ as one TypeScript file plus a shared core/ folder. React is the only dependency, so there's nothing to version-match.

Optionally, connect the shadcn MCP server so the agent can search the registry itself:

npx shadcn@latest mcp init --client claude

(Use cursor, vscode or opencode for other clients.)

2. Tell the agent how to use charts

Put the rules where the agent reads them every session: CLAUDE.md, AGENTS.md or .cursorrules.

## Charts

- Use the components in `components/charts/` for every chart. Don't write charts from scratch.
- Before choosing a chart, read https://chartslibraryui.com/llms.txt and follow each chart's "Avoid when".
- Install missing charts with `npx shadcn@latest add @chartslibraryui/<chart-name>`.
- Data is an array of row objects plus the keys to read. Use null for missing values, never 0.
- Percentages are fractions (0.12 = 12%). Use favorable="down" for costs, churn and latency.
- Never add a second y-axis. Use ComboChart, IndexChart or SmallMultiples.
- Every chart gets a title that states the takeaway and a subtitle with unit and period.

The llms.txt file lists every chart with a one-line purpose, so the agent can choose without guessing. llms-full.txt has the full docs and data shapes in one file if the agent can read long context.

3. Prompt for the dashboard

With the rules in place, short prompts work:

Build /dashboard for our SaaS metrics from lib/metrics.ts:
- a KPI row: MRR, net revenue retention, logo churn (lower is better)
- MRR by month for the last 18 months, with the next 3 months as forecast
- new MRR by channel last quarter, largest first
Use the chart components and follow the chart rules in CLAUDE.md.

The agent installs kpi-row, line-chart and horizontal-bar-chart, maps your data to data, x and series, and sets forecastFrom for the forecast months. Because the components own the styling, the agent writes a few lines per chart instead of a few hundred, which is faster and costs fewer tokens.

4. Review what the agent built

Even with good components, check the parts the agent decided:

  • Chart choice. Is a line used for change over time and bars for comparing categories? The chart pages list when not to use each chart.
  • Titles. Each should say something ("Churn fell for three months"), not just name the metric.
  • Formats. Currency, percent and units right? format="currency" and { kind: "percent" } handle the rest.
  • Missing data. Gaps should be gaps. If the agent filled nulls with 0, ask it to undo that.
  • The table view. Open it on one chart and compare a few values with the source.

Every chart shows a message instead of a drawing when the data is invalid (a string where a number should be, a negative value in a part-to-whole chart). If you see one, paste it back to the agent: it names the problem.

Why components beat prompting for style

You can get a consistent look by prompting, but you pay for it on every chart and every project, and it drifts. Components move the design decisions out of the conversation: the agent picks a chart and passes data, the style is already settled. The same rules then hold for the next dashboard, and the one after.

Try the free charts in your app

26 charts, MIT, one command each.