Components · Data Display
Bar Chart
BetaAdded v3.2.0
Compare values across categories, grouped or stacked. Server-rendered SVG on the chart palette.
import { BarChart } from '@nexub/react';Playground
Props
variant
size
legend
| month | 2026 | 2025 |
|---|---|---|
| May | $42k | $35k |
| Jun | $48k | $37k |
| Jul | $45k | $40k |
| Aug | $56k | $41k |
| Sep | $61k | $47k |
| Oct | $68k | $50k |
<BarChart className="w-full" data={data} index="month" series={…} valueFormat={(v) => `$${v}k`} title="Revenue by month" />Examples
Grouped
Stacked
Interactive
A crosshair and tooltip, keyboard point navigation, a toggle legend and `onPointClick`.
Waterfall
Rises in the good tone, falls in danger, totals from zero.
Horizontal and per-bar tones
States
Revenue by month month 2026 2025 May $42k $35k Jun $48k $37k Jul $45k $40k Aug $56k $41k Sep $61k $47k Oct $68k $50k defaultloadingRevenue by month month 2026 2025 May $42k $35k Jun $48k $37k Jul $45k $40k Aug $56k $41k Sep $61k $47k Oct $68k $50k size="sm"Revenue by month month 2026 2025 May $42k $35k Jun $48k $37k Jul $45k $40k Aug $56k $41k Sep $61k $47k Oct $68k $50k size="md"Revenue by month month 2026 2025 May $42k $35k Jun $48k $37k Jul $45k $40k Aug $56k $41k Sep $61k $47k Oct $68k $50k size="lg"Revenue by month month 2026 2025 May $42k $35k Jun $48k $37k Jul $45k $40k Aug $56k $41k Sep $61k $47k Oct $68k $50k variant="default"Revenue by month month 2026 2025 May $42k $35k Jun $48k $37k Jul $45k $40k Aug $56k $41k Sep $61k $47k Oct $68k $50k variant="waterfall"
Props
| Prop | Type | Default | Description |
|---|---|---|---|
| titlerequired | string | — | Accessible name of the chart and caption of its data table. |
| datarequired | T[] | — | One row per category, in order. |
| indexrequired | keyof T & string | — | Key of the category label in each row (the x axis). |
| seriesrequired | ChartSeries[] | — | { key, label?, color? } per series. color is 1–8 from the categorical chart palette; defaults to the series position. |
| valueFormat | ((value: number) => string) | defaultFormat | Formats axis labels, hover text and the data table. |
| size | 'sm' | 'md' | 'lg' | 'md' | Plot height: 8, 12 or 16rem. |
| legend | false | true | 'toggle' | true | Show the legend. Defaults to on for more than one series. |
| stacked | boolean | false | One bar per category with the series stacked. |
| series[].color | 1–8 | 'good' | 'warning' | 'danger' | 'neutral' | — | 11.3: a palette colour or a semantic tone. |
| series[].valueFormat | (value: number) => string | — | 11.3: formats this series in the tooltip and table (one currency per series). |
| integerTicks | boolean | — | 11.3: gridlines on whole numbers only (counts). Also 11.3: a null or missing value is drawn as a gap (no bar, a break in the line) and listed as "—", not counted as 0. |
| tableView | string | boolean | — | 11.3: a visible "Show as table" disclosure with the same data. Works without JS. |
| orientation | 'horizontal' | 'vertical' | — | 11.3: categories down the side for long names and ranked lists. |
| variant | 'default' | 'waterfall' | 'default' | 11.3: a waterfall of the first series from a running total; totalKey marks rows drawn from zero. |
| totalKey | (keyof T & string) | — | 11.3: a waterfall of the first series from a running total; totalKey marks rows drawn from zero. |
| colorOf | ((row: T, series: ChartSeries, index: number) => ChartPaint) | — | 11.3: a colour per bar (e.g. over budget in danger). |
| defaultHiddenSeries | string[] | — | Keys of the series hidden at first. |
| emptyState | React.ReactNode | — | Shown when there is no data. Defaults to the "no data" message. |
| errorState | React.ReactNode | — | Shown in place of the data when a load failed, for example an ErrorState with a retry action. Wins over loading and empty. |
| hiddenSeries | string[] | — | Keys of the hidden series, controlled (10.7). |
| interactive | boolean | — | A crosshair and tooltip that follow the pointer, and arrow-key navigation between points. |
| loading | boolean | — | Shows a skeleton in place of the data and sets aria-busy. |
| onHiddenSeriesChange | ((hidden: string[]) => void) | — | |
| onPointClick | ((point: ChartPoint<T>) => void) | — | Click, tap, or Enter/Space on a point. Turns interactive on unless it is set to false. |
Accessibility
Screen reader
The chart is a `figure` named by `title`. The drawing is hidden from assistive tech; a visually hidden table carries every value.
Colour is never the only cue: the legend and table name each series. Past six series, label directly or group the rest as "Other".
On iOS & Android
Web only
Bar Chart has no @nexub/react-native twin. On phones, follow the platform pattern instead, or compose it from the native components listed on the React Native page.