Install
Pull Chart from the barrel for everyday use, or the granular path when you want a tighter bundle.
import { Chart } from "@brika/clay";import { Chart } from "@brika/clay/components/chart";A minimal example
Drop this into a page. Native HTML attributes pass through to the underlying primitive.
import {
type ChartConfig,
ChartContainer,
ChartTooltip,
ChartTooltipContent,
} from '@brika/clay/components/chart';
import {
Bar,
BarChart,
CartesianGrid,
XAxis,
YAxis,
} from 'recharts';
const monthLabels = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun'] as const;
const compact = new Intl.NumberFormat('en-US', {
notation: 'compact',
maximumFractionDigits: 1,
});
/** Vertical bar chart with a single series, themed via `ChartContainer` config. */
export default function ChartBarDemo() {
const data = monthLabels.map((month, i) => ({
month,
visitors: 1820 + i * 240 + (i % 2) * 180,
}));
const config: ChartConfig = {
visitors: { label: 'Visitors', color: 'var(--data-1)' },
};
return (
<ChartContainer config={config} className="h-72 w-full">
<BarChart data={data} margin={{ top: 12, right: 12, left: 4, bottom: 0 }}>
<CartesianGrid vertical={false} />
<XAxis dataKey="month" tickLine={false} axisLine={false} />
<YAxis tickLine={false} axisLine={false} width={40} tickFormatter={(v) => compact.format(v)} />
<ChartTooltip content={<ChartTooltipContent indicator="line" />} />
<Bar dataKey="visitors" fill="var(--color-visitors)" radius={[6, 6, 0, 0]} />
</BarChart>
</ChartContainer>
);
}Chart, every way
Bar, Grouped
Two series rendered side-by-side, colour-keyed via the config palette.
Bar, Stacked
Stacked bar chart, bars share a column, totalled top-to-bottom.
Donut
Donut variant with a center label showing the running total.
KPI Dashboard
Sparklines compose into a KPI strip; each one keeps its own color via the data palette.
Labeled Axes
`xLabel`/`yLabel` add axis titles; tick formatters render dates and currency for a finance-style chart.
Line, Multi-series
Multi-series line chart with a dashed target overlay and a themed legend.
Live Stream
Live-streaming chart with controls, pick a metric, swap the time window, pause / resume the simulated feed.
Pie
Pie chart with a custom legend, segments map to the data palette via per-row `fill`.
Radar
Radar chart, multivariate comparison across labelled axes.
Radial
Radial bar chart, useful for goal-completion or capacity visualisations.
With Axes
`showAxes` reveals tick labels on both axes plus a faint grid; tooltip gets a timestamp header.
Accessibility
- Charts are visual, provide a
<caption>or adjacent text summary for screen readers. - Recharts renders an SVG; ensure the wrapper has
role="img"andaria-labeldescribing the data. - Tooltips visible on hover are not reliably announced by AT, critical data should also appear in text form.
Theme tokens
Every CSS variable Chart reads, with its default and the
dotted path you'd write in a ThemeConfig JSON
to override it. Set any of these in your theme to retune Chart
without touching component code.
Chart tokens
3 tokens--chart-tooltip-containercolorvar(--popover)components.chart.tooltipContainerBackground color of the chart tooltip surface. Defaults to the theme popover so tooltips read as floating UI.
--chart-tooltip-labelcolorvar(--popover-foreground)components.chart.tooltipLabelText color of the chart tooltip readout. Defaults to the theme popover foreground.
--chart-tooltip-bordercolorvar(--border)components.chart.tooltipBorderBorder color of the chart tooltip surface. Defaults to the theme border.
Override in a theme
Authoring a theme is plain JSON. Drop overrides under
components.chart, the names
are camelCase versions of the variable suffix.
{
"id": "my-theme",
"name": "My Theme",
"description": "...",
"accentSwatches": ["#000"],
"components": {
"chart": {
"tooltipContainer": "var(--popover)"
}
}
}
Then apply with applyTheme(myTheme)
(see the theming guide),
scope it to a subtree with themeToCssVars(myTheme, mode),
or consume any token directly in your own JSX with the matching Tailwind utility
(e.g. bg-chart-…) — see the
chips on each token row.
API reference
Props specific to Chart. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.
Chart exposes no wrapper-specific props.
All props pass through to the underlying HTML / Radix primitive, see the component source linked above for the full type signature.