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

Dependencies

More by Mahmoud Ilyan

View all
  • Steps

    Steps

    5
  • Radio Card

    Radio Card

    1
  • Switch

    Switch

    1
  • Textarea

    Textarea

  • Tabs

    Tabs

  • Progress

    Progress

  • KPI Card

    KPI Card

  • Checkbox Card

    Checkbox Card

More in Dashboards

View all
  • serf dashboard

    serf dashboard

    34
  • Dashboard with Collapsible Sidebar

    Dashboard with Collapsible Sidebar

    2.6K
  • Glass Dashboard

    Glass Dashboard

    675
  • Adjustable Glass Dashboard

    Adjustable Glass Dashboard

    1.1K
  • Dashboard Shell

    Dashboard Shell

    193
  • Stat Card

    Stat Card

    69
  • App Dashboard Layout

    App Dashboard Layout

    540
  • Chart Component

    Chart Component

    28