Skip to content
synccn

Stacked Bar Chart

New

Breakdowns over time as stacked totals or shares of 100%, with tooltips and a clickable legend.

Accounts by plan

Stacked bar chart
BarFreeProTeam
Jun82031090
Jul900360110
Aug860420150
Sep980470170
Oct1,040560220
Nov1,120640260

Installation

$ pnpm dlx shadcn@latest add @synccn/stacked-bar-chart

First time in this project? Connect synccn with one command.

Usage

import { StackedBarChart } from "@/components/ui/stacked-bar-chart";<StackedBarChart data={months} series={plans} />

API reference

Generated from the component's TypeScript types, so it always matches the code.

StackedBarChart

Stacked bars for breakdowns over time (plan mix, traffic by source), as totals or as shares of 100%. Hover a bar for its numbers; click legend items to hide a series.

  • datarequired
    ({ label: string } & Record<string, number | string>)[]

    One entry per bar: a label plus a value for each series key.

  • seriesrequired
    StackedBarSeries[]

    —

  • height
    number

    Default 240

    Height in pixels.

  • format
    (value: number) => string

    Default (v) => v.toLocaleString("en-US")

    Formats values on the axis and in the tooltip.

  • percent
    boolean

    Default false

    Shows each bar as shares of 100%.

  • className
    string

    Extra classes for the root element.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

npm packages

Accessibility

  • A visually hidden table holds every value. Legend items are toggle buttons with aria-pressed.

From the source

Read from this component's code when the site builds, so it can't drift.

  • ARIA roles: img
  • ARIA attributes: aria-labelledby, aria-pressed
  • Includes text only screen readers hear