Stacked Bar Chart
stacked-bar-chartBars split into the parts that make them up, on TanStack Charts. Layers keep the order you give them in every bar, `percent` compares the mix instead of the totals, and focus groups a whole bar so the tooltip lists every layer.
import { StackedBarChart } from "@/components/forme/stacked-bar-chart/stacked-bar-chart";
// Monthly recurring revenue in thousands, by plan.
const revenue = [
{ month: "Apr", starter: 18, team: 42, business: 64 },
{ month: "May", starter: 19, team: 47, business: 71 },
{ month: "Jun", starter: 21, team: 51, business: 80 },
{ month: "Jul", starter: 20, team: 58, business: 86 },
{ month: "Aug", starter: 22, team: 63, business: 97 },
{ month: "Sep", starter: 24, team: 69, business: 112 },
];
const thousands = (value: number) => `$${value}k`;
export function StackedBarChartDemo() {
return (
<div className="w-full rounded-xl border border-border bg-card p-5 lit edge">
<p className="text-caption-1-medium text-muted-foreground">MRR by plan</p>
<p className="mt-1 text-[1.75rem] leading-none font-semibold tracking-[-0.03em] tabular-nums">
$205k
</p>
<StackedBarChart
className="mt-5"
label="Monthly recurring revenue by plan, April to September"
data={revenue}
index="month"
formatValue={thousands}
series={[
{ key: "starter", label: "Starter" },
{ key: "team", label: "Team" },
{ key: "business", label: "Business" },
]}
/>
</div>
);
}Install
Adds the component, its registry dependencies, and the token stylesheet you import once.
API reference
Read from the source, so it is the API of the file you install. A prop marked * is required.
StackedBarChart
Bars split into the parts that make them up: revenue by plan, tickets by priority, spend by team.
| Prop | Type | Default | Description |
|---|---|---|---|
data* | readonly Row[] | — | |
index* | keyof Row & string | — | The field that labels each bar: a month, a region, a release. |
series* | readonly StackedBarSeries<Row>[] | — | The layers, bottom to top. Colours follow this order from --chart-1. |
label* | string | — | Accessible name. Say what is stacked and over what. |
percent | boolean | false | Each bar to 100%, so the mix compares rather than the totals. |
formatValue | (value: number) => string | plain | |
height | number | 280 | |
className | string | — |
Related


Chart
The tooltip and legend every Forme chart shares: a floating panel with a colour, a name and a right-aligned value per series, and a row of swatches. Installed with any chart; use them directly to give a chart of your own the same finish.
data display

Composed Chart
Columns and a line on one axis, on TanStack Charts: volume against its target, actuals against the plan. Rounded columns side by side, the line drawn over them, and a band cursor that lists every series in the column.
data display

Heatmap Chart
A grid of cells whose colour carries a quantity, on TanStack Charts: activity by weekday and hour, scores by team and quarter. Six steps of one hue from the sunken surface to the chart accent, optional values in the cells, and a tooltip on every cell.
data display