Components
A set of composable chart primitives built on Recharts, providing a themeable ChartContainer plus ChartTooltip, ChartTooltipContent, ChartLegend and ChartLegendContent. Colors are driven by a typed ChartConfig and exposed as CSS variables, so the same wrappers render bar, line, area, pie, radar, radial and composed charts with consistent styling in light and dark mode.
Loading preview...
"use client";
import { Bar, BarChart } from "recharts";
import { type ChartConfig, ChartContainer } from "@/components/ui/cnippet-chart";
const chartData = [
{ desktop: 186, mobile: 80, month: "January" },
{ desktop: 305, mobile: 200, month: "February" },
{ desktop: 237, mobile: 120, month: "March" },
{ desktop: 73, mobile: 190, month: "April" },
{ desktop: 209, mobile: 130, month: "May" },
{ desktop: 214, mobile: 140, month: "June" },
];
const chartConfig = {
desktop: {
color: "#2563eb",
label: "Desktop",
},
mobile: {
color: "#60a5fa",
label: "Mobile",
},
} satisfies ChartConfig;
export default function ChartExample() {
return (
<ChartContainer className="min-h-50 w-full" config={chartConfig}>
<BarChart accessibilityLayer data={chartData}>
<Bar dataKey="desktop" fill="var(--color-desktop)" radius={4} />
<Bar dataKey="mobile" fill="var(--color-mobile)" radius={4} />
</BarChart>
</ChartContainer>
);
}
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...
Loading preview...