LatestArea Charts

Bar Charts

Compare values across categories — vertical, grouped, horizontal or stacked.

Bar Chart
Site energy
September — pick a series to plot.
Bar Chart

Default

Compare values across categories — vertical, grouped, horizontal or stacked.

Bar Chart

Multiple

Bar Chart

Horizontal

Bar Chart

Stacked with legend

Bar Chart

Horizontal with labels

Bar Chart

Value labels

Bar Chart

Negative values

Bar Chart

Mixed colours

Bar Chart

Active bar

Installation

pnpm dlx shadcn@latest add https://kagadmodyaa.vercel.app/r/chart.json

Needs a React + Tailwind project set up with shadcn. Copies the component source straight into your project, so you can edit it.

Chart imports cn() from lib/utils.ts — add it too if you don't have it yet:

import { clsx, type ClassValue } from 'clsx'
import { twMerge } from 'tailwind-merge'

export function cn(...inputs: ClassValue[]) {
  return twMerge(clsx(inputs))
}

Every chart shares one foundation, the chart component — installing it also adds recharts. The examples on this page are what you copy into your own components.

A few interactive examples are built with other components from this site — card, toggle-group, tabs and select. Add the ones an example imports; the chart itself needs none of them.

Series are painted from a five-colour palette. The CLI adds these variables for you; on a manual install, add them to your global CSS:

:root {
  --chart-1: oklch(0.63 0.23 36);
  --chart-2: oklch(0.55 0.2 252);
  --chart-3: oklch(0.58 0.16 145);
  --chart-4: oklch(0.78 0.18 75);
  --chart-5: oklch(0.52 0.015 260);
}

.dark {
  --chart-1: oklch(0.72 0.19 36);
  --chart-2: oklch(0.66 0.19 252);
  --chart-3: oklch(0.68 0.17 145);
  --chart-4: oklch(0.85 0.17 75);
  --chart-5: oklch(0.72 0.012 260);
}

@theme inline {
  --color-chart-1: var(--chart-1);
  --color-chart-2: var(--chart-2);
  --color-chart-3: var(--chart-3);
  --color-chart-4: var(--chart-4);
  --color-chart-5: var(--chart-5);
}

Usage

import { Bar, BarChart, CartesianGrid, XAxis } from 'recharts'
import { ChartContainer, ChartTooltip, ChartTooltipContent, type ChartConfig } from '@/components/ui/chart'

const data = [
  { month: 'Jan', desktop: 420 },
  { month: 'Feb', desktop: 510 },
]

// Each key becomes --color-<key>; the label is what the tooltip and legend show.
const config = {
  desktop: { label: 'Desktop', color: 'var(--chart-1)' },
} satisfies ChartConfig

<ChartContainer config={config}>
  <BarChart data={data}>
    <CartesianGrid vertical={false} />
    <XAxis dataKey="month" tickLine={false} axisLine={false} />
    <ChartTooltip content={<ChartTooltipContent />} />
    <Bar dataKey="desktop" fill="var(--color-desktop)" radius={4} />
  </BarChart>
</ChartContainer>

API Reference

NameTypeDefaultDescription
ChartContainer configRecord<string, { label: string; color?: string }>—Required. One entry per series (or pie slice). Each key becomes the CSS variable --color-<key>; colour defaults to --chart-1, --chart-2, … in order.
ChartContainer childrenReactElement—Required. One Recharts chart (AreaChart, BarChart, …). It is wrapped in a ResponsiveContainer for you.
ChartContainer classNamestringaspect-video min-h-[200px] w-fullSizes the chart. Override the aspect ratio or height here — e.g. mx-auto aspect-square w-full max-w-[280px] for polar charts.
ChartTooltipContent indicator'dot' | 'line' | 'dashed''dot'How each row’s colour marker is drawn.
ChartTooltipContent hideLabelbooleanfalseHide the heading (the x-axis value).
ChartTooltipContent hideIndicatorbooleanfalseHide the colour markers.
ChartTooltipContent nameKeystring—Field of the data row that holds the name to look up in config — used by pie and radial charts.
ChartTooltipContent labelKeystring—Field of the data row to use as the heading instead of the axis value.
ChartTooltipContent labelFormatter(label, payload) => ReactNode—Format the heading.
ChartTooltipContent formatter(value, name, item) => ReactNode—Replace how a row’s value is rendered (numbers use thousands separators by default).
ChartLegendContent hideIconbooleanfalseHide the colour swatches.
ChartLegendContent nameKeystring—Field of the data row that holds the name to look up in config — used by pie charts.