uibrik

Stacked Bars

Preview

Customize

Stacked
Currency
Months12

Usage

import { StackedBars } from "@/components/uibrik/stacked-bars/stacked-bars";

<StackedBars />

Installation

npx shadcn@latest add https://uibrik.com/r/stacked-bars.json
Adds the files to components/uibrik/stacked-bars and installs @number-flow/react, @tabler/icons-react, motion and react-use-measure. With the @uibrik namespace set up: npx shadcn@latest add @uibrik/stacked-bars.

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.