Chart
Beautiful charts built on Recharts v3. Compose Recharts primitives inside ChartContainer and theme everything through chart config.
Installation#
pnpm dlx shadcn@latest add @davinciui/chartUsage#
We do not wrap Recharts — build charts with Recharts components and bring in ChartTooltip or ChartLegend only where needed. Always keep a height, min-h-*, or aspect-* on ChartContainer so ResponsiveContainer can measure on first render. Use var(--chart-1) (not hsl(var(--chart-1))) when referencing chart tokens, and add accessibilityLayer for keyboard and screen-reader support.
Composition#
ChartContainer wraps the Recharts chart and exposes shared theme tokens to the tooltip and legend parts:
ChartContainer
├── Recharts <BarChart /> / <LineChart /> / <AreaChart />
├── ChartTooltip
│ └── ChartTooltipContent
└── ChartLegend
└── ChartLegendContentAPI Reference#
| Prop | Type | Default |
|---|---|---|
configLabels, icons, and colors per data key. Generates --color-* tokens. | ChartConfig | — |
labelHuman-readable label for a config entry. | ReactNode | — |
colorhex, hsl, oklch, or var(--chart-*) token. | string | — |
themePer-mode colors. Use instead of color, not with it. | { light: string; dark: string } | — |
indicatorTooltip indicator style (ChartTooltipContent). | "dot" | "line" | "dashed" | "dot" |
hideLabelHide the tooltip label row. | boolean | false |
hideIndicatorHide the tooltip color indicator. | boolean | false |
labelKeyCustom key for the tooltip label. | string | — |
nameKeyCustom key for tooltip and legend names. | string | — |
accessibilityLayerRecharts keyboard + screen-reader support on the chart. | boolean | false |
Accessibility#
ChartContainer only provides theming and sizing, so keyboard and screen-reader support depends on passing Recharts accessibilityLayer. The custom tooltip and legend render as unlabeled divs without ARIA roles.
Motion#
The wrapper adds no motion. Any animation comes from Recharts itself, such as isAnimationActive on series, and this file has no prefers-reduced-motion handling.
View source
Keep in mind
Need a custom component?
I build bespoke UI components & websites tailored to your brand.

