Skip to content
misoto22 design

Charts

BarChart

Discrete categories compared by length.

When to reach for it

The categories are buckets rather than a continuum. If the axis is time and the reader is following a trend, an AreaChart or LineChart reads it faster.

Examples

default

Visitors by month
Visitors by month
monthDesktopMobile
Jan18680
Feb305200
Mar237120
Apr273190
May209130
Jun314240

fill variants

Visitors by month — default
Visitors by month — default
Desktop
186
305
237
273
209
314

stacking and orientation

Visitors by channel — default, vertical
Visitors by channel — default, vertical
DesktopMobile
18680
305200
237120
173190

emphasis

Glowing
Glowing
Desktop
186
305
237
273
209
314
Buffer — the last period is still open
Buffer — the last period is still open
Desktop
186
305
237
273
209
314
Hover highlight
Hover highlight
Desktop
186
305
237
273
209
314

interaction

Visitors by month
Visitors by month
DesktopMobile
18680
305200
237120
273190

brush

Visitors by day
Visitors by day
dayDesktop
D190
D2176
D3241
D4270
D5254
D6198
D7115
D8153
D9226
D10266
D11263
D12217
D13140
D14129
D15208
D16259
D17268
D18234
D19164
D20104
D21188
D22248
D23270
D24248
D25187
D26102
D27166
D28235

loading

Visitors by month
Loading

value labels

Visitors by month
Visitors by month
Desktop
1,860
30,500
23,700
27,300
9,200
31,400

sonify

Revenue by month
Revenue by month
monthRevenueRefunds
Jan18,6001,240
Feb30,500980
Mar23,7002,310
Apr27,3001,150
May9,2003,040
Jun31,400870

toolbar

Visitors by month

Arrow keys pan by one point, Page Up and Page Down by a screenful, Home and End jump to the ends. Plus and minus zoom, zero resets. Ctrl and the wheel zoom around the pointer, and dragging across the plot zooms to that span.

Showing Jan 25 to Dec 26, 24 of 24 points

Visitors by month
monthDesktop
Jan 251,200
Feb 251,534
Mar 251,837
Apr 252,077
May 252,235
Jun 252,296
Jul 252,258
Aug 252,131
Sep 251,932
Oct 251,687
Nov 251,428
Dec 251,189
Jan 26999
Feb 26884
Mar 26861
Apr 26937
May 261,108
Jun 261,360
Jul 261,669
Aug 262,005
Sep 262,337
Oct 262,631
Nov 262,861
Dec 263,004

Notes

Discrete categories compared by length — the shape for "how much, per thing".

Reach for <AreaChart> or <LineChart> when the axis is continuous and the reader is following a trend rather than comparing buckets.

Props

BarChart props
PropTypeDefaultDescription
childrenrequiredReactNodeThe composed parts — axes, grid, tooltip, legend, and the marks themselves.
configrequiredTConfig & ValidateKeys<TData, TConfig>
datarequiredTData[]The rows the chart draws. One entry per point, bar or category.
titlerequiredstringWhat the chart shows, in a sentence a reader could act on. Required, and announced to a screen reader even when it is not printed.
animationTypeChartRevealType'forward'The grow-in order every `<BarChart.Bar>` inherits.
barCategoryGapnumberGap between categories.
barGapnumberGap between bars inside one category.
barRadiusnumberBAR_RADIUSThe corner every `<BarChart.Bar>` inherits.
chartPropsComponentProps<typeof RechartsBarChart>Escape hatch onto the raw Recharts chart element.
classNamestringMerged onto the figure, last, so a call site can size or space it.
defaultSelectedDataKeystring | nullnullThe series lit on first render. Selection dims every other series.
descriptionReactNodeA line under the title — the unit, the window, the caveat.
emptyChartEmptyProps | falseWhat the chart shows when it has nothing to draw. Rendered instead of the plot whenever `data` is empty and the chart is not loading — the state a real dashboard reaches within a week, and the one an empty pair of axes is indistinguishable from a failed load. `false` keeps the axes, for a chart whose emptiness is itself the reading.
hideDataTablebooleanfalseDrops the hidden table view. Only correct when the page prints the data itself.
isLoadingbooleanfalseSwaps the marks for an animated skeleton, keeping the measured height so the page does not jump when the data lands.
loadingBarsnumberHow many bars the skeleton draws.
onSelectionChange(selectedDataKey: string | null) => voidFires when the selection changes, and with null when it is cleared.
orientationBarOrientation'vertical'Which way the bars run. Reach for `horizontal` when the category names are long enough to need rotating under a column.
showTitlebooleanPrints the title above the plot instead of hiding it from sight.
stackTypeBarStackType'default'How several marks combine: side by side, stacked, or normalised to 100%.
xDataKeykeyof TData & stringThe row field on the category axis. Needed by the brush and by the table view.

Types

TSX
export type BarVariant = 'default' | 'hatched' | 'duotone' | 'duotone-reverse' | 'gradient' | 'stripped'
export type BarStackType = 'default' | 'stacked' | 'percent'
export type BarOrientation = 'vertical' | 'horizontal'

Accessibility

  • title is required; the rows are also rendered as a visually hidden table.
  • Every bar carries an invisible full-height hit rectangle, so a 3px bar at the bottom of the scale is as easy to hit as a full-height one.
  • A clickable legend entry is a real button with aria-pressed, not a div with a click handler.
  • The staggered grow-in is anchored to the chart’s own start rather than to each bar’s mount, so a hover cannot replay it — and reduce-motion drops it entirely.