Skip to content

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'

On this page
  1. One series
  2. Stacked
  3. Grouped
  4. Skeleton
  5. When to use it
  6. For everyone
  7. Props

One series

New users
Per month, 2026
0200400600JanMarMayJulSep
View as table
MonthNew users
Jan212
Feb248
Mar301
Apr290
May344
Jun402
Jul388
Aug451
Sep520
Oct596
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
05,00010K15KMonTueWedThuFriSatSun
View as table
DaySucceededRejectedFailed
Mon8,20064090
Tue9,10070060
Wed8,800820310
Thu9,600760120
Fri10.4K91080
Sat5,20038040
Sun4,10030030
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%
0 ms100 ms200 ms300 msSão PauloVirginiaFrankfurtMumbai
View as table
RegionTypicalSlowest 5%
São Paulo38 ms120 ms
Virginia24 ms88 ms
Frankfurt31 ms96 ms
Mumbai52 ms210 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
0100200300JulAugSepOctNov
View as table
Sign-ups
Jul120
Aug180
Sep150
Oct240
Nov210
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

BarChartTypeDefault
seriesrequired Series[]
titlerequired ReactNode
xrequired

The positions along the horizontal axis: dates, hours, names.

string[]
empty ReactNode
error ReactNode
formatValue

How 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
stacked

Series on top of each other (parts of a total) instead of side by side.

boolean false
subtitle ReactNode
xLabel

The header of the first column of the table view: what `x` is.

string
  1. One series
  2. Stacked
  3. Grouped
  4. Skeleton
  5. When to use it
  6. For everyone
  7. Props

    Search pages, sections and terms