Chart

Recharts wrapper with theme-aware series colors, tooltip, and legend.

Examples

Bar chart with tooltip and legend

Stacked bar chart

Line chart

Area chart

Composed chart (bar + line)

Donut chart

Radar chart

Radial bar chart

Scatter chart

Overview

ChartContainer wraps Recharts' ResponsiveContainer and injects a --color-<key> CSS variable per series from its config, so marks can reference fill="var(--color-<key>)" / stroke="var(--color-<key>)" and stay theme-aware. Colors given as theme: { light, dark } switch automatically with the .dark class.

The chart components compose with Recharts primitives — import chart types (BarChart, LineChart, Bar, Line, axes, …) directly from recharts.

tsx
import {
  ChartContainer,
  ChartTooltip,
  ChartTooltipContent,
  type ChartConfig,
} from "@rogo-technologies/ui/chart";
import { Bar, BarChart, XAxis } from "recharts";

const config: ChartConfig = {
  revenue: { label: "Revenue", color: "rgb(var(--chart-1))" },
};

<ChartContainer config={config} className="min-h-48 w-full">
  <BarChart data={data}>
    <XAxis dataKey="month" />
    <ChartTooltip content={<ChartTooltipContent />} />
    <Bar dataKey="revenue" fill="var(--color-revenue)" />
  </BarChart>
</ChartContainer>;

Usage

Series colors

Use the shared chart tokens --chart-1--chart-5 (see Colors). They are RGB channel triples, so wrap them in rgb():

tsx
const config: ChartConfig = {
  revenue: { label: "Revenue", color: "rgb(var(--chart-1))" },
  expenses: { label: "Expenses", color: "rgb(var(--chart-2))" },
};

For colors that differ per theme, pass a theme object instead of color:

tsx
const config: ChartConfig = {
  price: { label: "Price", theme: { light: "#1B8C6C", dark: "#2AA37F" } },
};

Tooltip

ChartTooltip is Recharts' Tooltip; pass ChartTooltipContent as its content for the Rogo-styled card. Labels resolve from the chart config, and formatter / labelFormatter customize values.

tsx
<ChartTooltip
  content={<ChartTooltipContent indicator="line" formatter={(value) => formatUsd(value)} />}
/>

Legend

ChartLegend is Recharts' Legend; pass ChartLegendContent as its content. Series labels and optional icons come from the chart config.

tsx
<ChartLegend content={<ChartLegendContent />} />

API

ChartContainer

PropTypeDefaultDescription
configChartConfigPer-series label, optional icon, and color or theme: { light, dark }.
childrenRecharts chart elementA single Recharts chart (BarChart, LineChart, …).
idstringautoStable id for the injected per-series CSS variables.
classNamestringMerged onto the container (defaults include aspect-video; override freely).

ChartTooltipContent

PropTypeDefaultDescription
indicator"dot" | "line" | "dashed""dot"Marker style next to each series row.
hideLabelbooleanfalseHide the tooltip header label.
hideIndicatorbooleanfalseHide the series color marker.
formatter(value, name, item, …) => ReactNodeReplace the default row rendering per entry.
labelFormatter(label, payload) => ReactNodeCustomize the header label.
nameKeystringConfig lookup key for series names.
labelKeystringConfig lookup key for the header label.

ChartLegendContent

PropTypeDefaultDescription
verticalAlign"top" | "bottom""bottom"Adjusts padding toward the chart.
hideIconbooleanfalseHide config icons, show color swatches.
nameKeystringConfig lookup key for series names.

Guidelines

Do

  • Use the shared --chart-1--chart-5 tokens so series colors stay consistent and theme-aware
  • Give every series a label in the config — the tooltip and legend read from it
  • Size charts with className on ChartContainer (it defaults to aspect-video)

Don't

  • Don't use more than 5 series colors in one chart (see Colors)
  • Don't hardcode hex colors on marks — reference var(--color-<key>) from the config
  • Don't wrap ChartContainer in another ResponsiveContainer — it already provides one
PreviousCard
Made in NYC© 2026 Rogo Technologies Inc.