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 { CartesianGrid, Line, LineChart, XAxis, YAxis } from "recharts";
const monthly = [
{ month: "Jan", revenue: 12400 },
{ month: "Feb", revenue: 15600 },
{ month: "Mar", revenue: 18200 },
{ month: "Apr", revenue: 17100 },
{ month: "May", revenue: 21500 },
{ month: "Jun", revenue: 24800 },
];
const lineConfig = {
revenue: {
label: "Revenue",
theme: { light: "var(--color-chart-1)", dark: "var(--color-chart-1)" },
},
} satisfies ChartConfig;
export default function Demo() {
return (
<ChartContainer
config={lineConfig}
ariaLabel="Monthly revenue trend, January to June"
className="aspect-[16/9] max-h-[280px] 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 indicator="line" />}
/>
<Line
dataKey="revenue"
type="monotone"
stroke="var(--color-revenue)"
strokeWidth={2}
dot={false}
/>
</LineChart>
</ChartContainer>
);
}
















