Bar Chart

Grouped, stacked and horizontal bars that grow in, rescale and reorder with springs.

Preview

Revenue by region

Demo data, in thousands of dollars

Illustrative revenue by region data
CategorySubscriptionsServicesMarketplace
North America$66K$75K$31K
Europe$102K$61K$36K
Asia Pacific$72K$50K$36K
Latin America$29K$23K$25K
Middle East$51K$16K$13K
Africa$23K$18K$6K

Install

Add it with the shadcn CLI, or copy the source manually.

$ bunx --bun shadcn add @beui/bar-chart

API Reference

BarChart

series
readonly XYSeries[]

Nonnegative values aligned with categories. Missing or negative values leave a gap.

—
categories
readonly string[]

Unique category labels in display order.

—
layout?
"grouped" | "stacked"
—
orientation?
"horizontal" | "vertical"
—
sort?
"none" | "ascending" | "descending"

Order categories by their visible total. Bars glide to their new place when it changes.

—
max?
number

Fixed top of the value axis. Defaults to a rounded value above the tallest bar.

—
activeId?
string | null

Inspected category, by label.

—
defaultActiveId?
string | null
—
onActiveChange?
((id: string | null) => void)
—
hiddenSeries?
readonly string[]

Series ids hidden through the legend.

—
defaultHiddenSeries?
readonly string[]
—
onHiddenSeriesChange?
((ids: readonly string[]) => void)
—
formatValue?
((value: number) => string)
—
formatTick?
((value: number) => string)

Axis tick labels. Defaults to compact notation (1.2K).

—
label?
string
—
className?
string
—

BarChartLegend

className?
string
—

BarChartPlot

height?
number

Plot height in px. Horizontal charts default to 36px per category.

—
labelWidth?
number

Width of the category label gutter for horizontal bars, in px.

96
showGrid?
boolean
true
className?
string
—

BarChartTooltip

className?
string
—
side?
"bottom" | "left" | "right" | "top"
top

Updated