import { ChartCard } from "@elabs-ai/components-charts";npm install @elabs-ai/components-tokens @elabs-ai/components-ui @elabs-ai/components-chartsPaste it into Claude Code, Cursor, Codex or any other coding agent. Text in [brackets] is yours to fill in.
Add the brand-ui ChartCard chart (from @elabs-ai/components-charts) to this project. 1. Read https://elabs-ai.com/llms.txt first: it maps every package and the rules. If you can use MCP servers, connect https://elabs-ai.com/mcp and use its search, docs and tokens tools. If not, run the same lookups in the terminal: `npx -y @elabs-ai/components-cli search "<what you need>"` and `npx -y @elabs-ai/components-cli docs <Component>`. 2. Look ChartCard up before writing code: `npx -y @elabs-ai/components-cli docs ChartCard` prints its real props, variants, what it pairs with and what to avoid. 3. If @elabs-ai/components-charts is not installed yet: `pnpm add @elabs-ai/components-tokens @elabs-ai/components-ui @elabs-ai/components-charts` (or `npm install @elabs-ai/components-tokens @elabs-ai/components-ui @elabs-ai/components-charts`). If this is the first brand-ui package in the project, wire it once: import `@elabs-ai/components-tokens/styles.css` plus the `themes/light.css` and `themes/dark.css` stylesheets in the CSS entry, add one Tailwind `@source` line per installed @elabs-ai package (Tailwind does not scan node_modules, so without it everything renders unstyled), and wrap the app root in `ThemeProvider` from `@elabs-ai/components-tokens`. 4. Use it here: [the screen or file, and what it should show] 5. Rules: use only @elabs-ai/components-* components and the semantic tokens — no raw colours, no raw font sizes, no arbitrary Tailwind values. Look up each component's real props with the docs tool before you use it; never guess a prop. 6. Done means: the typecheck passes, `npx -y @elabs-ai/components-cli audit src --strict` reports nothing, and you have opened the app and looked at every screen you touched in the light and the dark theme.
Avoid
- Nesting a ChartCard inside a Card — it already IS the surface.
- Hand-building expand / flip-to-table / download controls on the card — wrap it with ChartFrame instead.
- Leaving the body blank when data is absent — render the loading/empty state; a blank card reads as broken.
Works with
Used inside
Pairs with
Examples
With Actions
Tall Height
Loading
Loading vs ready (#268) — title/description keep rendering; the body becomes a skeleton.
With Source
The card contract's fourth part (lieflat) — an attribution/provenance footer, rendered all-caps and letter-spaced. `title` is the conclusion, `description` is the legend in prose, `source` is where the data came from.
Title Only
Empty State Heading Order
`ChartCard` titling a real page section (`titleAs="h2"`) whose body is a `StatePanel` empty state (`titleAs="h3"`) — the two components' outline levels compose correctly (#385): `<h2>` then `<h3>`, no skip, no un-headinged title `<div>` sitting between them. Locks the axe `heading-order` fix at the source (`ChartCard.titleAs` forwarded to `CardTitle`, `StatePanel.titleAs` replacing the old hardcoded `<h3>`).
API
ChartCard
| Prop | Type | Description |
|---|---|---|
titlerequired | ReactNode | Write the title as the CONCLUSION, not the chart type — "Revenue is up 8% QoQ", not "Revenue chart". Put what each series means in prose in `description` (lieflat's card contract). |
titleAs | "div" | "h1" | "h2" | "h3" | "h4" | "h5" | "h6" | Heading level for the card's title, forwarded to `CardTitle`'s own `as` prop (#328). Set this when the card titles a real page section so it contributes to the document outline. @default "div" |
description | ReactNode | Prose that IS the legend — what a reader needs to read the chart correctly (series, units, scope), written as a sentence, not a caption. |
actions | ReactNode | Header actions (range picker, menu). |
childrenrequired | ReactNode | The chart itself. Bring your own chart lib (Recharts, visx, etc.). |
height | number | Fixed body height so charts have a sizing context. Defaults to 260. |
loading | boolean | Loading vs ready — the body becomes a layout-shaped skeleton at the same height; title/description keep rendering. Default: `false`. |
source | ReactNode | Attribution / provenance footer — e.g. "Source: Internal analytics, updated daily". Renders as the card's all-caps, letter-spaced source row (the fourth part of lieflat's card contract); hidden when absent. A string that overflows the row stays fully recoverable — a native `title` and, once it measurably overflows, a keyboard-reachable tooltip (#184). A non-string node keeps only the CSS caps with no overflow recovery — keep it short, or accept it may be visually truncated with no fallback. |
Theming
The tokens each state resolves to. Change the token and every theme follows.
| State | Token |
|---|---|
| background | bg-card text-card-foreground — inherited: ChartCard IS a Card (it adds only layout) |