BarChart
Compares amounts across a few categories or periods. Bars always start at zero, so their length can be trusted.
import { BarChart } from '@sypnia/ui/react'
One series
New users
Per month, 2026
View as table
| Month | New users |
|---|---|
| Jan | 212 |
| Feb | 248 |
| Mar | 301 |
| Apr | 290 |
| May | 344 |
| Jun | 402 |
| Jul | 388 |
| Aug | 451 |
| Sep | 520 |
| Oct | 596 |
Code
import { BarChart } from '@sypnia/ui/react';
export default function Signups() {
return (
<BarChart title="New users" subtitle="Per month, 2026" xLabel="Month"
x={['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct']}
series={[{ id: 'users', label: 'New users', data: [212, 248, 301, 290, 344, 402, 388, 451, 520, 596] }]} />
);
} Stacked
Requests by result
Per day, this week. Parts of a total are stacked.
- Succeeded
- Rejected
- Failed
View as table
| Day | Succeeded | Rejected | Failed |
|---|---|---|---|
| Mon | 8,200 | 640 | 90 |
| Tue | 9,100 | 700 | 60 |
| Wed | 8,800 | 820 | 310 |
| Thu | 9,600 | 760 | 120 |
| Fri | 10.4K | 910 | 80 |
| Sat | 5,200 | 380 | 40 |
| Sun | 4,100 | 300 | 30 |
Code
import { BarChart } from '@sypnia/ui/react';
const days = ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'];
export default function Stacked() {
return (
<BarChart stacked title="Requests by result" subtitle="Per day, this week. Parts of a total are stacked." xLabel="Day" x={days}
series={[
{ id: 'ok', label: 'Succeeded', data: [8200, 9100, 8800, 9600, 10400, 5200, 4100] },
{ id: 'client', label: 'Rejected', data: [640, 700, 820, 760, 910, 380, 300] },
{ id: 'server', label: 'Failed', data: [90, 60, 310, 120, 80, 40, 30] },
]} />
);
} Grouped
Response time
Milliseconds, by region. Things compared side by side are grouped.
- Typical
- Slowest 5%
View as table
| Region | Typical | Slowest 5% |
|---|---|---|
| São Paulo | 38 ms | 120 ms |
| Virginia | 24 ms | 88 ms |
| Frankfurt | 31 ms | 96 ms |
| Mumbai | 52 ms | 210 ms |
Code
import { BarChart } from '@sypnia/ui/react';
export default function Grouped() {
return (
<BarChart title="Response time" subtitle="Milliseconds, by region. Things compared side by side are grouped." xLabel="Region" height={220}
x={['São Paulo', 'Virginia', 'Frankfurt', 'Mumbai']} formatValue={(v) => `${v} ms`}
series={[{ id: 'p50', label: 'Typical', data: [38, 24, 31, 52] }, { id: 'p95', label: 'Slowest 5%', data: [120, 88, 96, 210] }]} />
);
} Skeleton
The real piece and its skeleton: the same box, so nothing moves when the data arrives.
Sign-ups
Per month
View as table
| Sign-ups | |
|---|---|
| Jul | 120 |
| Aug | 180 |
| Sep | 150 |
| Oct | 240 |
| Nov | 210 |
Sign-ups
Per month
Code
import { BarChart, ChartSkeleton } from '@sypnia/ui/react';
// On the first load a chart can pass `loading` with no data, or the page can draw ChartSkeleton before it knows anything.
export default function Skeleton() {
return (
<div className="sy-grid">
<BarChart title="Sign-ups" subtitle="Per month" x={['Jul', 'Aug', 'Sep', 'Oct', 'Nov']} height={200} series={[{ id: 's', label: 'Sign-ups', data: [120, 180, 150, 240, 210] }]} />
<BarChart title="Sign-ups" subtitle="Per month" x={[]} height={200} series={[]} loading />
</div>
);
} When to use it
Use it when
- A few things are compared by size: users per month, response time per region.
- Parts that add up to a total per period: stacked.
- Two or three measures of the same unit, side by side: grouped (the default with several series).
Do not use it when
- Many points over time (hours of a day, days of a year): a LineChart reads better.
- The bars would be coloured by how big they are. One series is one colour; length already says the size.
- Parts of one single total: use PartToWhole instead of one stacked bar or a pie.
For everyone
- Every bar can be reached with Tab and announces its category, series and value.
- Bars are separated by gaps of the background, not by outlines, so they stay distinct for everyone.
- «View as table» shows the same numbers as a table.
Props
| BarChart | Type | Default |
|---|---|---|
seriesrequired | Series[] | |
titlerequired | ReactNode | |
xrequiredThe positions along the horizontal axis: dates, hours, names. | string[] | |
empty | ReactNode | |
error | ReactNode | |
formatValueHow a value is written in ticks, tooltip and table. Defaults to a compact number in the person's language. | ((v: number) => string) | |
height | number | |
loading | boolean | |
stackedSeries on top of each other (parts of a total) instead of side by side. | boolean | false |
subtitle | ReactNode | |
xLabelThe header of the first column of the table view: what `x` is. | string |