100% Stacked Bar Chart for React
A React 100% stacked bar chart that scales every bar to 100%, so you can compare the mix inside each category whatever its size. Pass data as readonly ChartRow[]: one object per bar: the index key plus one number per series key (shares are worked out for you).
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/percent-bar-chart.jsonPlan mix by region
- Free
- Pro
- Team
PercentBarChartPercentBarTablepercentSharesdefaultPercentBarChartLabels- +2 more
Horizontal, with shares
showValues prints a share inside a segment only when it fits with room to spare, on a surface chip that passes contrast on any color. Up/Down move between regions, Left/Right between segments.
Plan mix by region
Customers on each plan
- Free
- Pro
- Team
import { ChartCard } from "@/components/sheenui/charts/chart-parts/chart-card";
import { seriesLegend } from "@/components/sheenui/charts/chart-parts/legend-tooltip";
import { type ChartSeries } from "@/components/sheenui/charts/chart-utils";
import { PercentBarTable, PercentBarChart } from "@/components/sheenui/charts/percent-bar-chart";
// Package build (after the first npm release, or a packed tarball): import { ChartCard, seriesLegend, PercentBarTable, PercentBarChart, type ChartSeries } from "@sheenui/theme";
const data = [
{ region: "North America", free: 4200, pro: 2600, team: 1400 },
{ region: "Europe", free: 5100, pro: 2100, team: 900 },
{ region: "Asia Pacific", free: 7400, pro: 1500, team: 600 },
{ region: "Latin America", free: 2600, pro: 700, team: 180 },
];
const series: ChartSeries[] = [
{ key: "free", label: "Free", color: 1 },
{ key: "pro", label: "Pro", color: 2 },
{ key: "team", label: "Team", color: 3 },
];
export function Example() {
return (
<ChartCard
title="Plan mix by region"
legend={seriesLegend(series, "rect")}
table={<PercentBarTable data={data} index="region" series={series} />}
>
<PercentBarChart showValues data={data} index="region" series={series} aria-label="Share of customers on each plan, by region" />
</ChartCard>
);
}Files to copy
11 folders · 25 files · 4 packages
- From
theme/src/ components/charts/{percent-bar-chart.tsx, chart-export-menu.tsx, chart-export.ts, chart-figure.tsx, chart-fit.tsx, chart-icons.tsx, chart-parts.tsx, chart-patterns.tsx, chart-utils.ts}components/charts/chart-parts/components/drawer/parts/sheet.tsxcomponents/kbd/components/menu/components/skeleton/components/status-icons/hooks/{use-controllable.ts, use-intersection.ts, use-latest.ts, use-media-query.ts, use-preferences.ts}motion/tokens.tslib/{cn.ts, csv.ts, form.ts, glide-highlight.tsx, heading.ts, math.ts, popup-a11y.ts, popup-motion.ts, warn-once.ts}styles/
- shadcn CLI
npx shadcn@latest add https://lokendra-builds.github.io/sheenui/r/percent-bar-chart.jsonRegistry item: percent-bar-chart. The styles need the Tailwind v4 glass UI setup.- Packages
pnpm add @base-ui/react clsx motion tailwind-merge
Next.js: samples here pass functions (formatters, seriesLegend, a dashboard's load), so put them in a file that starts with "use client".
Vertical columns
layout="vertical". Left/Right move between quarters, Up/Down climb the stack.
Sessions by device
- Desktop
- Mobile
- Tablet
import { type ChartSeries } from "@/components/sheenui/charts/chart-utils";
import { PercentBarChart } from "@/components/sheenui/charts/percent-bar-chart";
// Package build (after the first npm release, or a packed tarball): import { PercentBarChart, type ChartSeries } from "@sheenui/theme";
const data = [
{ quarter: "Q1 ’25", desktop: 41000, mobile: 39000, tablet: 5800 },
{ quarter: "Q2 ’25", desktop: 38500, mobile: 43500, tablet: 5500 },
{ quarter: "Q3 ’25", desktop: 36200, mobile: 47800, tablet: 5300 },
{ quarter: "Q4 ’25", desktop: 33800, mobile: 52400, tablet: 5000 },
];
const series: ChartSeries[] = [
{ key: "desktop", label: "Desktop", color: 1 },
{ key: "mobile", label: "Mobile", color: 2 },
{ key: "tablet", label: "Tablet", color: 3 },
];
export function Example() {
return <PercentBarChart layout="vertical" data={data} index="quarter" series={series} aria-label="Share of sessions by device" />;
}Zero rows and long names
A category whose values add up to 0 gets an empty track instead of a misleading bar; long names truncate (the full name is in the tooltip and the table).
Time spent by team
- Building
- Meetings
- Support
import { type ChartSeries } from "@/components/sheenui/charts/chart-utils";
import { PercentBarChart } from "@/components/sheenui/charts/percent-bar-chart";
// Package build (after the first npm release, or a packed tarball): import { PercentBarChart, type ChartSeries } from "@sheenui/theme";
const series: ChartSeries[] = [
{ key: "building", label: "Building", color: 1 },
{ key: "meetings", label: "Meetings", color: 2 },
{ key: "support", label: "Support", color: 3 },
];
export function Example() {
return (
<PercentBarChart
showValues
data={[
{ name: "Platform infrastructure and reliability", building: 52, meetings: 30, support: 18 },
{ name: "Design", building: 61, meetings: 31, support: 8 },
{ name: "New team", building: 0, meetings: 0, support: 0 }, // drawn as an empty track
]}
index="name"
series={series}
format={(n) => n + " h"}
aria-label="Share of time by activity, per team"
/>
);
}PercentBarChart props
PercentBarChartLabels keys and English defaults (4)
PercentBarTable props
Keyboard
Accessibility
- Keyboard and screen-reader users get a single focusable figure labelled by the chart title, with a short reading hint as its description; inside a ChartCard with a table view, aria-details links it to the table. Every value read is announced politely, once. Each move announces the segment's value and its share.
- For a non-visual reading, give ChartCard's table prop a PercentBarTable; the Chart / Table tabs then expose each value as plain table cells.
- With reduced motion on, the segments start at their final shares and a data change jumps straight to the new state.
All exports on this page
PercentBarChart— Bars that all add up to 100%, so each bar shows the mix rather than the size.PercentBarTable— The table view of a part-to-whole chart (PercentBarChart, or StackedAreaChart in percent mode).defaultPercentBarChartLabels— The built-in English strings of PercentBarChart; spread it into your own labels and change what you need.percentShares— Shares (0–100) of each series in each row.
When to use the 100% stacked bar chart
- Use it as a percentage bar chart for a plan mix by region, where Free, Pro and Team customers are counted in very different volumes and you care about each region's proportions rather than its size.
- It suits time-spent breakdowns by team, such as building, meetings and support, where every row must be read as a share of 100% and long team names truncate inside a horizontal layout.
- Choose layout vertical for a quarterly device mix, where columns line up like a time series and the arrow keys climb each stack, with showValues printing a share only where a segment has room.
- Skip it when the absolute totals matter as much as the split; a regular BarChart keeps the size of each category visible, and Marimekko chart shows both width and share together.
- Pair it with ChartCard for the title, legend and Chart / Table tabs, seriesLegend for the swatches, and PercentBarTable so every share can be read as text without relying on color.
Frequently asked questions
Related pages
48 charts pages in all: browse them on Charts.
By Lokendra Singh Rathore (GitHub, opens in a new tab). Published , updated .