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.
| month | Revenue | Expenses |
|---|---|---|
| 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.
| month | Subscriptions | Services | Payroll | Tools |
|---|---|---|---|---|
| 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.
| page | Page views |
|---|---|
| /pricing | 18,420 |
| /docs/getting-started | 15,310 |
| /blog/launch-week | 11,270 |
| /changelog | 7,940 |
| /customers | 5,180 |
API
BarChart
| Prop | Type | Default | Description |
|---|---|---|---|
| data | Record<string, unknown>[] | — | One record per category. |
| index | string | — | Key of the category in each record. |
| series | { key, label?, color? }[] | — | color is 'series-1'…'series-6' or any CSS colour. |
| stacked | boolean | false | One bar per category, segments stacked. |
| orientation | 'vertical' | 'horizontal' | 'vertical' | Direction the bars grow. |
| radius | number | 4 | Corner radius of the rounded end, in px. |
| height | number | 280 | Plot 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 / yAxis | boolean | options | true | Bottom and left axes. yAxis.format, ticks and domain always apply to the value axis. |
| grid | boolean | 'horizontal' | 'vertical' | 'both' | true | true draws lines along the value axis. |
| legend | 'top' | 'bottom' | false | bottom when there are 2+ series | Toggles series. |
| tooltip | boolean | { labelFormat } | true | Shows every series for the hovered category. |
| animate | boolean | true | Bars grow from the baseline on mount. |
Keyboard
| Key | Action |
|---|---|
| Tab | Focuses the chart. |
| ← / → or ↑ / ↓ | Moves to the previous or next category. |
| Home / End | First or last category. |
| Esc | Clears 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.