Installation
Theme
Mode

Data viz

Bar chart

The first of the chart family — hand-rolled SVG dressed entirely in our system: Geist axes, tokened gridlines, a dark tooltip that matches the rest of the kit, and the fixed Orbit series palette. One component, four layouts.

$npx shadcn@latest add @orbit/bar-chart

Overview

Discrete categories compared by length. Hover a bar for exact values.

Tasks completed — this week
Tasks completed
This week · hover a bar
+18%

Variants

A single variant prop switches between vertical columns, horizontal bars, grouped series, and stacked totals — same data, same theme.

vertical — columns for a value over a short series (default)
horizontal — when category labels are long or ranking matters
grouped — several series side by side within a category
CompletedIn reviewTo do
stacked — parts that sum to a meaningful total per category
CompletedIn reviewTo do

Options

Drop the gridlines for a minimal look, print values on the bars, or recolor a single-series chart with one accent token.

showValues · showGrid=false
accent="var(--acc)"

In context

Sitting in a stat card beside the metrics it explains — the throughput panel of a project dashboard, with a working range toggle.

Completed
272+18%
Avg / week
45+6%
Carried over
13−9%
Throughput by month
CompletedIn reviewTo do

Props

PropTypeDefaultDescription
variant"vertical" | "horizontal" | "grouped" | "stacked""vertical"Layout. vertical/horizontal plot data; grouped/stacked plot categories + series.
data{ label: string; value: number }[]Single-series rows for vertical | horizontal.
categoriesstring[]Category labels for grouped | stacked.
series{ name: string; values: number[]; color?: string }[]Multi-series values. Colors default to the fixed CHART_SERIES palette by position.
accentstring"var(--pri)"Single-series bar color (any token or color-mix).
heightnumber340Total height in px, legend included. Width is responsive.
showGridbooleantrueHairline gridlines across the value axis.
showValuesbooleanfalsePrints values beside the bars (single-series variants).
showLegendbooleantrueLegend under multi-series charts. Never rendered for one series.
namestring"Value"Single-series name shown in the tooltip.
formatValue(v: number) => stringStringFormats tooltip, axis, and printed values.
ariaLabelstringPlain-language summary for the chart's role=“img”.
…restHTMLAttributes<HTMLDivElement>Forwarded to the root div, including ref and className.

Usage

Bars compare discrete categories — keep the comparison honest and easy to read.

Do

Start the value axis at zero

Bars encode length — a non-zero baseline exaggerates differences and misleads. The scale here always includes zero.

Don’t

Stack unrelated series

Only stack parts that genuinely sum to a meaningful whole, or the total is noise.

Do

Go horizontal for long labels

When category names are wordy, horizontal bars keep them readable without rotation.

Don’t

Crowd in too many series

Past three or four grouped bars per category the comparison gets hard — split it up, or fold the long tail into “Other”.

Keyboard & accessibility

The chart renders as a labelled image with its data available on demand; identity never rides on color alone.

roleimg with an aria-label summary of the data
TooltipExact values for every series on hover
ContrastSeries palette holds ≥ 3:1 on both modes
LegendNames series beyond color alone