Cnippet

Chart

Dashboards 2

About

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.

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 { Pie, PieChart } from "recharts";
import {
  type ChartConfig,
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
} from "@/components/ui/cnippet-chart";

export const description = "A simple pie chart";

const chartData = [
  { browser: "chrome", fill: "var(--color-chrome)", visitors: 275 },
  { browser: "safari", fill: "var(--color-safari)", visitors: 200 },
  { browser: "firefox", fill: "var(--color-firefox)", visitors: 187 },
  { browser: "edge", fill: "var(--color-edge)", visitors: 173 },
  { browser: "other", fill: "var(--color-other)", visitors: 90 },
];

const chartConfig = {
  chrome: {
    color: "var(--chart-1)",
    label: "Chrome",
  },
  edge: {
    color: "var(--chart-4)",
    label: "Edge",
  },
  firefox: {
    color: "var(--chart-3)",
    label: "Firefox",
  },
  other: {
    color: "var(--chart-5)",
    label: "Other",
  },
  safari: {
    color: "var(--chart-2)",
    label: "Safari",
  },
  visitors: {
    label: "Visitors",
  },
} satisfies ChartConfig;

export default function ChartPieSimple() {
  return (
    <ChartContainer
      className="mx-auto aspect-square max-h-62.5 w-full"
      config={chartConfig}
    >
      <PieChart>
        <ChartTooltip
          content={<ChartTooltipContent hideLabel />}
          cursor={false}
        />
        <Pie data={chartData} dataKey="visitors" nameKey="browser" />
      </PieChart>
    </ChartContainer>
  );
}

Dependencies

More by Cnippet

View all
  • Team

    Team

    1.3K
  • Davincho Hero-1

    Davincho Hero-1

    704
  • Aero Hero-3

    Aero Hero-3

    612
  • Random Letter Swap Navigation

    Random Letter Swap Navigation

    553
  • Features

    Features

    529
  • Services with Animated Hover Modal

    Services with Animated Hover Modal

    485
  • Blogs

    Blogs

    403
  • Aero Hero-1

    Aero Hero-1

    376

More in Dashboards

View all
  • Dashboard with Collapsible Sidebar

    Dashboard with Collapsible Sidebar

    2.6K
  • Sidebar

    Sidebar

    386
  • Stat Card

    Stat Card

    33
  • Fitness Bento Grid

    Fitness Bento Grid

    35
  • SaaS Template

    SaaS Template

    2.7K
  • Stats Bento

    Stats Bento

    1.2K
  • Course Design Cards

    Course Design Cards

    1.3K
  • Financial Bento Grid

    Financial Bento Grid

    125