Controls

Stacked Bar Chart

Effect
Preview
Reduced motion

Simulates prefers-reduced-motion for the demo. Off follows your system setting.

Keyboard stepping

Steps focus through the demo with ] and [. Tab, arrows, and Escape stay native so the component behaves as shipped.

Stacked Bar Chart
  • Free
  • Pro
  • Team

Accounts by plan
monthFreeProTeam
Jan1204012
Feb1505218
Mar1706125
Apr1657031
May1988436
Jun2309647

Stacked Bar Chart

A bar chart that stacks each series into one column per label.

Installation

npx shadcn@latest add ikislay/pixel-ui/stacked-bar-chart

How to use

import { StackedBarChart } from "@/components/ui/stacked-bar-chart"
const data = [
{ month: "Jan", free: 120, pro: 40, team: 12 },
{ month: "Feb", free: 150, pro: 52, team: 18 },
{ month: "Mar", free: 170, pro: 61, team: 25 },
]
export function Demo() {
return (
<StackedBarChart
label="Plans by month"
data={data}
index="month"
series={[

Source Code

// Loading…

Props

Options you can pass to customize this component.

Prop
Type
Description
data*
Record<string, string | number>[]

One object per point along the x axis.

index*
string

The key in each object that labels the x axis.

series*
{ key: string; label?: string; color?: string }[]

The keys to plot. Colors follow the chart palette in order unless you set one. Negative values count as zero.

label*
string

Names the chart for screen readers and captions its data table.

height
number

Height in pixels. The width fills the parent.

format
(value: number) => string

Formats values wherever the chart shows them. Defaults to short numbers like 12.4K.

radius
number

Corner radius at the top of each column. It shrinks to fit a short column.

className
string

Merged onto the root element.