Bar Chart
<BarChart />TailwindCSS ModulesVisualize trends and comparisons in dashboards with responsive bar charts.
npx coloxo add bar-chart --style coloxo-cssimport { BarChart } from '@coloxo/ui';Compare categories. Follow trends. Build clearer dashboards.
1. Bar chart examples
Explore simple, grouped, horizontal, and stacked views of the same visitor data.
Bar Chart - Default
Desktop visitors, January-June
- Desktop
| Category | Desktop |
|---|---|
| January | 186 |
| February | 305 |
| March | 237 |
| April | 73 |
| May | 209 |
| June | 214 |
Bar Chart - Multiple
Compare desktop and mobile visitors
- Desktop
- Mobile
| Category | Desktop | Mobile |
|---|---|---|
| January | 186 | 80 |
| February | 305 | 200 |
| March | 237 | 120 |
| April | 73 | 190 |
| May | 209 | 130 |
| June | 214 | 140 |
Bar Chart - Horizontal
Compare categories side by side
- Desktop
| Category | Desktop |
|---|---|
| January | 186 |
| February | 305 |
| March | 237 |
| April | 73 |
| May | 209 |
| June | 214 |
Bar Chart - Stacked
See each channel's contribution
- Desktop
- Mobile
| Category | Desktop | Mobile |
|---|---|---|
| January | 186 | 80 |
| February | 305 | 200 |
| March | 237 | 120 |
| April | 73 | 190 |
| May | 209 | 130 |
| June | 214 | 140 |
2. Interactive configurator
Width is relative to the preview. Height sets the SVG reference height; the chart scales proportionally to fit.
- Desktop
- Mobile
| Category | Desktop | Mobile |
|---|---|---|
| January | 186 | 80 |
| February | 305 | 200 |
| March | 237 | 120 |
| April | 73 | 190 |
| May | 209 | 130 |
| June | 214 | 140 |
<BarChart label="Monthly visitors" data={data} series={series} color="brand" layout="vertical" stacked={false} showGrid={true} showLegend={true} height={280} style={{ width: "100%" }}/>3. Enterprise layout compositions
Combine charts with summary metrics and context for revenue reviews and resource planning. All figures below are sample data.
Revenue performance
Actual revenue against monthly targets · January–April
- Actual revenue
- Target revenue
| Category | Actual revenue | Target revenue |
|---|---|---|
| January | $42k | $45k |
| February | $53k | $48k |
| March | $49k | $50k |
| April | $61k | $55k |
Team capacity
Weekly planning · 40 hours allocated per team
- Planned hours
- Available hours
| Category | Planned hours | Available hours |
|---|---|---|
| Engineering | 32h | 8h |
| Design | 24h | 16h |
| Operations | 28h | 12h |
import { BarChart, Card, Statistic } from "@coloxo/ui";const data = [ { "label": "January", "actual": 42, "target": 45 }, { "label": "February", "actual": 53, "target": 48 }, { "label": "March", "actual": 49, "target": 50 }, { "label": "April", "actual": 61, "target": 55 }];<Card variant="default" className="p-6"> <Statistic label="Revenue to date" value="205" prefix="$" suffix="k" /> <BarChart label="Monthly revenue versus target" data={data} series={[ { key: "actual", label: "Actual revenue" }, { key: "target", label: "Target revenue" }, ]} valueFormatter={(value) => `$${value}k`} /></Card>4. Actions & composition
Pair a chart with period filters, CSV export, and a visible data table. Every action below uses the selected period.
Visitor analytics
Desktop and mobile acquisition · Sample data
- Desktop
- Mobile
| Category | Desktop | Mobile |
|---|---|---|
| January | 186 | 80 |
| February | 305 | 200 |
| March | 237 | 120 |
| April | 73 | 190 |
| May | 209 | 130 |
| June | 214 | 140 |
| Month | Desktop | Mobile |
|---|---|---|
| January | 186 | 80 |
| February | 305 | 200 |
| March | 237 | 120 |
| April | 73 | 190 |
| May | 209 | 130 |
| June | 214 | 140 |
5. Dark theme
- Desktop
- Mobile
| Category | Desktop | Mobile |
|---|---|---|
| January | 186 | 80 |
| February | 305 | 200 |
| March | 237 | 120 |
| April | 73 | 190 |
| May | 209 | 130 |
| June | 214 | 140 |
Accessibility
Each chart has an accessible name, keyboard-focusable bars, and a screen-reader data table. Hover or focus bars to inspect values.
Hover or focus a bar to see its category, series, and formatted value in the shared ChartTooltip. Press Escape to dismiss it. Use descriptive series labels and distinguish series through the legend. Positive and negative values share a zero baseline. Empty datasets display a clear empty state.
Props
| Name | Type | Default | Description |
|---|---|---|---|
| data | BarChartDatum[] | — | Category label and numeric values keyed by series. Non-finite or missing values render as zero. |
| series | BarChartSeries[] | — | Unique key, display label, and optional CSS color for each series. |
| color | "brand" | "gray" | "error" | "warning" | "success" | "blue" | "indigo" | "purple" | "pink" | "orange" | brand | Primary series color. The secondary series mixes the primary with 45% white. Per-series CSS colors override the palette. |
| label | string | — | Required accessible chart name. |
| layout | "vertical" | "horizontal" | vertical | Direction of the bars. |
| stacked | boolean | false | Stack series within each category. Supports positive and negative values. |
| height | number | 280 | SVG viewBox height; the chart scales to fit its container. Minimum 160. |
| showLegend / showGrid | boolean | true | Display the series legend and value grid. |
| valueFormatter | (value: number) => string | — | Format axis labels, bar descriptions, and accessible data. |
| className / style | string / CSSProperties | — | Customize the chart container. |