About
A composable chart container that wraps Recharts with theme-aware colors, an accessible tooltip, and a legend for building line, bar, area, donut, and sparkline charts.
Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Chart to your project and fits it to your theme.
Code
How Chart is used: the demo's code. The component's own source comes with a free account.
Usage.tsx
"use client";
import {
ChartContainer,
ChartTooltip,
ChartTooltipContent,
type ChartConfig,
} from "@/components/ui/chart";
import { Bar, BarChart, CartesianGrid, XAxis, YAxis } from "recharts";
const channels = [
{ channel: "Email", signups: 1240 },
{ channel: "Search", signups: 980 },
{ channel: "Social", signups: 760 },
{ channel: "Direct", signups: 540 },
{ channel: "Referral", signups: 320 },
];
const barConfig = {
signups: {
label: "Signups",
theme: { light: "var(--color-chart-1)", dark: "var(--color-chart-1)" },
},
} satisfies ChartConfig;
export default function Demo() {
return (
<ChartContainer
config={barConfig}
ariaLabel="Signups by channel for March"
className="aspect-[16/9] max-h-[280px] w-full"
>
<BarChart
data={channels}
margin={{ top: 8, right: 16, bottom: 0, left: 0 }}
>
<CartesianGrid vertical={false} strokeDasharray="3 3" />
<XAxis dataKey="channel" tickLine={false} axisLine={false} />
<YAxis tickLine={false} axisLine={false} />
<ChartTooltip
cursor={{ fill: "var(--color-bg)" }}
content={<ChartTooltipContent />}
/>
<Bar
dataKey="signups"
fill="var(--color-signups)"
radius={[4, 4, 0, 0]}
/>
</BarChart>
</ChartContainer>
);
}
















