Chart
Recharts primitives wired to the system's theme and tooltip.
Installation
npx shadcn@latest add @blank/chartUsage
import {
ChartContainer,
ChartTooltip,
ChartTooltipContent,
type ChartConfig,
} from "@/components/ui/chart"const config = {
desktop: { label: "Desktop", color: "var(--chart-1)" },
} satisfies ChartConfig
<ChartContainer config={config} className="h-60">
<BarChart data={data}>
<ChartTooltip content={<ChartTooltipContent />} />
<Bar dataKey="desktop" fill="var(--color-desktop)" radius={4} />
</BarChart>
</ChartContainer>Charts are Recharts components. The container turns each config key into a --color-<key> variable scoped to that chart, so series colors come from tokens and follow the theme. --chart-1 to --chart-5 are steps of one ink, darkest first; give a series a status role such as var(--danger-primary) only when it means one, like the failures above.
Examples
Line
indicator="line" on the tooltip and a legend from the same config.
Stacked area
API Reference
ChartContainer
Every div prop, plus:
| Prop | Type | Default |
|---|---|---|
config | ChartConfig | — |
initialDimension | { width: number; height: number } | { width: 320, height: 200 } |
ChartConfig
One entry per series: { label?: ReactNode; icon?: ComponentType } and either color (one value) or theme ({ light, dark }).
ChartTooltipContent
Recharts tooltip content props, plus:
| Prop | Type | Default |
|---|---|---|
indicator | "dot" | "line" | "dashed" | "dot" |
hideLabel | boolean | false |
hideIndicator | boolean | false |
nameKey | string | — |
labelKey | string | — |
ChartLegendContent
| Prop | Type | Default |
|---|---|---|
hideIcon | boolean | false |
nameKey | string | — |