GitHub

Bar Chart

CSS-only bar chart component with vertical and horizontal orientations, stacked bars, compact mode, grid lines, color variants, and glass styling. No JavaScript required for rendering.

Basic Vertical

Preview
45
Mon
72
Tue
58
Wed
90
Thu
35
Fri
65
Sat
80
Sun

With Sub-values

Preview
$1.2k +12%
Q1
$1.8k +28%
Q2
$950 -8%
Q3
$2.1k +35%
Q4

Horizontal

Preview
Chrome
65%
Safari
18%
Firefox
8%
Edge
5%
Other
4%

Color Variants

Preview
A
B
C
D
A
B
C
D
A
B
C
D
A
B
C
D

Per-bar Colors

Preview
Sales
Q1
Costs
Q1
Sales
Q2
Costs
Q2

Size Variants

Preview

bar-chart-sm (160px)

A
B
C
D
E

bar-chart (default, 240px)

A
B
C
D
E

bar-chart-lg (320px)

A
B
C
D
E

Compact (Mini Bar Chart)

Preview
Weekly trend

Grid Lines

Preview
120
Jan
185
Feb
150
Mar
220
Apr
175
May
240
Jun

Glass Variant

Preview
$4.2k
Jan
$5.8k
Feb
$3.9k
Mar
$7.1k
Apr
$6.3k
May

Stacked Bars

Preview
$3.2k
Q1
$4.5k
Q2
$2.8k
Q3
$5.1k
Q4

No Dot Indicator

Preview
Mon
Tue
Wed
Thu
Fri

Classes Reference

Class Description
.bar-chartMain container. Flex row, items aligned to bottom. Default height 240px.
.bar-chart-itemIndividual bar column container (flex-1, full height)
.bar-chart-barThe bar element. Set height via inline style (e.g. style="height: 60%")
.bar-chart-valueValue container displayed above the bar
.bar-chart-value-mainPrimary value text (bold, colored)
.bar-chart-value-subSecondary value text (smaller, muted)
.bar-chart-labelLabel displayed below the bar
.bar-chart-bar-no-dotHides the dot indicator at the top of the bar
.bar-chart-horizontalHorizontal orientation. Bars grow left-to-right. Use width instead of height.
.bar-chart-bar-stackedStacked bar container (add to .bar-chart-bar). Contains segments.
.bar-chart-bar-segmentIndividual segment inside a stacked bar
.bar-chart-primaryPrimary color variant (default)
.bar-chart-successSuccess (green) color variant
.bar-chart-warningWarning (yellow/orange) color variant
.bar-chart-errorError (red) color variant
.bar-chart-smSmall size (160px height, tighter gap)
.bar-chart-lgLarge size (320px height, wider gap)
.bar-chart-compactMini sparkline-style (60px, no labels/values/dots, minimal gap)
.bar-chart-gridAdds horizontal grid lines at 25%, 50%, 75%
.bar-chart.glassGlassmorphism background with blur and border
--bar-colorCSS custom property for per-bar color (set via inline style)