Mahmoud Ilyan

Chart

Dashboards

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>
  );
}

Dependencies

More by Mahmoud Ilyan

View all
  • Steps

    Steps

    5
  • Radio Card

    Radio Card

    1
  • Switch

    Switch

    1
  • Input

    Input

    1
  • Badge

    Badge

    1
  • Textarea

    Textarea

  • Tabs

    Tabs

  • Progress

    Progress

More in Dashboards

View all
  • Creator Dashboard

    Creator Dashboard

    75
  • serf dashboard

    serf dashboard

    75
  • Dashboard with Collapsible Sidebar

    Dashboard with Collapsible Sidebar

    2.6K
  • Glass Dashboard

    Glass Dashboard

    1.1K
  • Adjustable Glass Dashboard

    Adjustable Glass Dashboard

    1.2K
  • App Dashboard Layout

    App Dashboard Layout

    560
  • Chart Component

    Chart Component

    43
  • Sidebar

    Sidebar

    421