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,
ChartLegend,
ChartLegendContent,
type ChartConfig,
} from "@/components/ui/chart";
import { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts";
const monthly = [
{ month: "Jan", revenue: 12400, refunds: 800 },
{ month: "Feb", revenue: 15600, refunds: 1100 },
{ month: "Mar", revenue: 18200, refunds: 950 },
{ month: "Apr", revenue: 17100, refunds: 1300 },
{ month: "May", revenue: 21500, refunds: 1450 },
{ month: "Jun", revenue: 24800, refunds: 1200 },
];
const multiLineConfig = {
revenue: {
label: "Revenue",
theme: { light: "var(--color-chart-1)", dark: "var(--color-chart-1)" },
},
refunds: {
label: "Refunds",
theme: { light: "var(--color-chart-4)", dark: "var(--color-chart-4)" },
},
} satisfies ChartConfig;
export default function Demo() {
return (
<ChartContainer
config={multiLineConfig}
ariaLabel="Monthly revenue and refunds, January to June"
className="aspect-[16/9] max-h-[300px] w-full"
>
<LineChart
data={monthly}
margin={{ top: 8, right: 16, bottom: 0, left: 0 }}
>
<CartesianGrid vertical={false} strokeDasharray="3 3" />
<XAxis dataKey="month" tickLine={false} axisLine={false} />
<YAxis
tickLine={false}
axisLine={false}
tickFormatter={(v) => `$${(v / 1000).toFixed(0)}k`}
/>
<ChartTooltip
cursor={{ stroke: "var(--color-chart-grid)", strokeDasharray: "3 3" }}
content={<ChartTooltipContent />}
/>
<ChartLegend content={<ChartLegendContent />} />
<Line
dataKey="revenue"
type="monotone"
stroke="var(--color-revenue)"
strokeWidth={2}
dot={false}
/>
<Line
dataKey="refunds"
type="monotone"
stroke="var(--color-refunds)"
strokeWidth={2}
dot={false}
/>
</LineChart>
</ChartContainer>
);
}
















