ui-kit0.0

Charts

Bar chart

Compare values, grouped or stacked.

Usage

BarChart groups series side by side by default. Only the end of each bar is rounded. Hovering a category dims the others and highlights its slot.

Bar chart of Revenue, Expenses, 6 points from Jan to Jun.
monthRevenueExpenses
Jan$18,400$12,100
Feb$20,250$12,900
Mar$19,600$14,300
Apr$23,100$13,800
May$25,800$15,200
Jun$24,900$16,700

When to use

  • Comparing values between categories or periods.
  • Showing the parts of each total (stacked), including values below zero.

Not for: dense time series with dozens of points (use a line or area chart).

Stacked with negative values

stacked piles the series. Positive values stack up from zero and negative ones stack down, so mixed data never overlaps, and a zero line is drawn when the chart crosses it.

Stacked bar chart of Subscriptions, Services, Payroll, Tools, 6 points from Jan to Jun.
monthSubscriptionsServicesPayrollTools
Jan$14,200$4,200-$9,800-$2,300
Feb$15,100$5,150-$9,800-$3,100
Mar$15,900$3,700-$10,400-$3,900
Apr$17,300$5,800-$10,400-$3,400
May$18,800$7,000-$11,200-$4,000
Jun$19,400$5,500-$11,200-$5,500

Horizontal

Use orientation="horizontal" for long labels. The left axis then shows the categories and the bottom axis the values.

Bar chart of Page views, 5 points from /pricing to /customers.
pagePage views
/pricing18,420
/docs/getting-started15,310
/blog/launch-week11,270
/changelog7,940
/customers5,180

API

BarChart

PropTypeDefaultDescription
dataRecord<string, unknown>[]—One record per category.
indexstring—Key of the category in each record.
series{ key, label?, color? }[]—color is 'series-1'…'series-6' or any CSS colour.
stackedbooleanfalseOne bar per category, segments stacked.
orientation'vertical' | 'horizontal''vertical'Direction the bars grow.
radiusnumber4Corner radius of the rounded end, in px.
heightnumber280Plot height in px.
valueFormat'number' | 'currency' | 'percent' | 'compact' | Intl options | (n) => string'number'Tooltip and axis value format.
indexFormat(value, i) => string—Formats the category everywhere.
xAxis / yAxisboolean | optionstrueBottom and left axes. yAxis.format, ticks and domain always apply to the value axis.
gridboolean | 'horizontal' | 'vertical' | 'both'truetrue draws lines along the value axis.
legend'top' | 'bottom' | falsebottom when there are 2+ seriesToggles series.
tooltipboolean | { labelFormat }trueShows every series for the hovered category.
animatebooleantrueBars grow from the baseline on mount.

Keyboard

KeyAction
TabFocuses the chart.
← / → or ↑ / ↓Moves to the previous or next category.
Home / EndFirst or last category.
EscClears the selection.

Accessibility

  • role="img" with a summary label and a visually hidden table of every value.
  • Active category is announced through a polite live region for keyboard users.
  • Colour is never the only cue: the legend and tooltip name each series.

Motion

  • Bars grow from the baseline over 500ms, staggered by at most 30ms, total under 700ms.
  • The highlight slot glides between categories; the other bars fade to 40%.
  • Reduced motion: bars appear in place.