Mahmoud Ilyan

Chart

Component

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, type ChartConfig } from "@/components/ui/chart";
import { Line, LineChart } from "recharts";

const sparkData = [
  { d: 1, v: 32 },
  { d: 2, v: 41 },
  { d: 3, v: 38 },
  { d: 4, v: 52 },
  { d: 5, v: 49 },
  { d: 6, v: 61 },
  { d: 7, v: 73 },
];

const sparklineConfig = {
  v: {
    label: "Visits",
    theme: { light: "var(--color-chart-1)", dark: "var(--color-chart-1)" },
  },
} satisfies ChartConfig;

export default function Demo() {
  return (
    <div className="flex items-center gap-3">
      <span className="text-2xl font-semibold tabular-nums text-ink-dark">
        2,840
      </span>
      <ChartContainer
        config={sparklineConfig}
        ariaLabel="Visits trend, last 7 days"
        className="h-10 w-32"
      >
        <LineChart
          data={sparkData}
          margin={{ top: 2, right: 2, bottom: 2, left: 2 }}
        >
          <Line
            dataKey="v"
            type="monotone"
            stroke="var(--color-v)"
            strokeWidth={2}
            dot={false}
            isAnimationActive={false}
          />
        </LineChart>
      </ChartContainer>
    </div>
  );
}

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