The chart gallery has area, bar, line, pie, radar and radial charts
plus tooltip variants. They are built on the shadcn/ui chart component,
which wraps Recharts and connects it to your theme.
Each chart in the gallery has its own command. For example:
pnpm dlx shadcn@latest add https://ui.tealmac.com/r/chart-area-default.json
The CLI adds the chart file, the chart and card primitives and the
recharts package.
Each chart keeps its data and config at the top of the file. Replace them with yours:
import { type ChartConfig } from "@/components/ui/chart"
const chartData = [
{ month: "January", desktop: 186, mobile: 80 },
{ month: "February", desktop: 305, mobile: 200 },
]
const chartConfig = {
desktop: { label: "Desktop", color: "var(--chart-1)" },
mobile: { label: "Mobile", color: "var(--chart-2)" },
} satisfies ChartConfigThe keys in chartConfig match the keys in your data. ChartContainer turns
each entry into a CSS variable (--color-desktop, --color-mobile), which
the Recharts elements use:
<Area
dataKey="desktop"
fill="var(--color-desktop)"
stroke="var(--color-desktop)"
/>Series colours come from --chart-1 to --chart-5. Every
theme and preset sets them for light and dark, so
charts change with the rest of the UI. To fix a series to a colour, put any
CSS colour in its color field, or pass theme: { light, dark } instead.
accessibilityLayer prop to the chart element for keyboard
focus and screen reader descriptions.isAnimationActive={false} when the visitor prefers reduced motion.