Black Friday: 30% off Pro

Get 30% off

Updated

Stacked Bars

Pro

Preview

Customize

Stacked
Currency
Months12

Installation

Pro

Stacked Bars is a Pro component

Sign in to see the source, or install it with a license key. The live preview and props above are free to explore.

Install with a key

  1. Add the Pro registry to components.json:
    components.json
    {
      "registries": {
        "@uibrik-pro": {
          "url": "https://uibrik.com/r/pro/{name}.json",
          "headers": { "Authorization": "Bearer ${UIBRIK_LICENSE}" }
        }
      }
    }
  2. Put your key in .env.local and add that file to .gitignore:
    .env.local
    UIBRIK_LICENSE=your-license-key
  3. Install it:
    Terminal
    npx shadcn@latest add @uibrik-pro/stacked-bars

Usage

import { StackedBars } from "@/components/uibrik/stacked-bars/stacked-bars";​const series = [  { key: "starter", label: "Starter" },  { key: "pro", label: "Pro" },  // …1 more];​<StackedBars  title="Revenue by plan"  defaultMode="stacked"  series={series}  onModeChange={(mode) => {}}  // data={[{ label: "…" }]}  // mode="stacked"/>

Where to use Stacked Bars

  • Revenue by segment

    Monthly columns split by series show both totals and parts.

    Pairs with Area Chart

  • Category trends

    Sliding apart into groups makes comparing one series across months easy.

  • Marketing reports

    A legend that folds series away focuses on the channels that matter.

Props

StackedBars
title
Type string
"Revenue by plan"
Names what is plotted.
defaultMode
Type "stacked" | "grouped"
"stacked"
Starting layout: one column per period, or series side by side.
data
Type { label: string; [key: string]: number }[]
–
One row per period, oldest first, with a value for each series key.
series
Type { key: string; label: string; color?: string }[]
–
The series to draw, bottom of the stack first.
mode
Type "stacked" | "grouped"
–
Controls the layout. Pair with onModeChange.
onModeChange
Type (mode) => void
–
Called when the layout tabs change.
format
Type Intl.NumberFormatOptions
USD currency
Formats every number, e.g. { style: "percent" }.
className
Type string
–
Classes for the outer shell.