Bar Chart

The BarChart component visualizes labeled numeric values as accessible vertical bars.

Usage & Examples

Monthly Volume

Monthly volume
Jan: 24JanFeb: 38FebMar: 31MarApr: 47Apr
monthly-volume.tsx
const chartData = [
    { label: "Jan", value: 24, color: "#2f80ed" },
    { label: "Feb", value: 38, color: "#27ae60" },
    { label: "Mar", value: 31, color: "#f2994a" },
    { label: "Apr", value: 47, color: "#9b51e0" },
  ]; 
  
  
  <BarChart data={chartData} label="Monthly volume" />

Visual variants

Themes

primary
Monthly volume
Jan: 24JanFeb: 38FebMar: 31MarApr: 47Apr
secondary
Monthly volume
Jan: 24JanFeb: 38FebMar: 31MarApr: 47Apr
tertiary
Monthly volume
Jan: 24JanFeb: 38FebMar: 31MarApr: 47Apr
quaternary
Monthly volume
Jan: 24JanFeb: 38FebMar: 31MarApr: 47Apr

States

success
Monthly volume
Jan: 24JanFeb: 38FebMar: 31MarApr: 47Apr
warning
Monthly volume
Jan: 24JanFeb: 38FebMar: 31MarApr: 47Apr
error
Monthly volume
Jan: 24JanFeb: 38FebMar: 31MarApr: 47Apr
info
Monthly volume
Jan: 24JanFeb: 38FebMar: 31MarApr: 47Apr
visual-variants.tsx
// Themes
const chartData = [
    { label: "Jan", value: 24, color: "#2f80ed" },
    { label: "Feb", value: 38, color: "#27ae60" },
    { label: "Mar", value: 31, color: "#f2994a" },
    { label: "Apr", value: 47, color: "#9b51e0" },
  ]; 
  
  
  <BarChart theme="primary" data={chartData} label="Monthly volume" />
const chartData = [
    { label: "Jan", value: 24, color: "#2f80ed" },
    { label: "Feb", value: 38, color: "#27ae60" },
    { label: "Mar", value: 31, color: "#f2994a" },
    { label: "Apr", value: 47, color: "#9b51e0" },
  ]; 
  
  
  <BarChart theme="secondary" data={chartData} label="Monthly volume" />
const chartData = [
    { label: "Jan", value: 24, color: "#2f80ed" },
    { label: "Feb", value: 38, color: "#27ae60" },
    { label: "Mar", value: 31, color: "#f2994a" },
    { label: "Apr", value: 47, color: "#9b51e0" },
  ]; 
  
  
  <BarChart theme="tertiary" data={chartData} label="Monthly volume" />
const chartData = [
    { label: "Jan", value: 24, color: "#2f80ed" },
    { label: "Feb", value: 38, color: "#27ae60" },
    { label: "Mar", value: 31, color: "#f2994a" },
    { label: "Apr", value: 47, color: "#9b51e0" },
  ]; 
  
  
  <BarChart theme="quaternary" data={chartData} label="Monthly volume" />

// States
const chartData = [
    { label: "Jan", value: 24, color: "#2f80ed" },
    { label: "Feb", value: 38, color: "#27ae60" },
    { label: "Mar", value: 31, color: "#f2994a" },
    { label: "Apr", value: 47, color: "#9b51e0" },
  ]; 
  
  
  <BarChart state="success" data={chartData} label="Monthly volume" />
const chartData = [
    { label: "Jan", value: 24, color: "#2f80ed" },
    { label: "Feb", value: 38, color: "#27ae60" },
    { label: "Mar", value: 31, color: "#f2994a" },
    { label: "Apr", value: 47, color: "#9b51e0" },
  ]; 
  
  
  <BarChart state="warning" data={chartData} label="Monthly volume" />
const chartData = [
    { label: "Jan", value: 24, color: "#2f80ed" },
    { label: "Feb", value: 38, color: "#27ae60" },
    { label: "Mar", value: 31, color: "#f2994a" },
    { label: "Apr", value: 47, color: "#9b51e0" },
  ]; 
  
  
  <BarChart state="error" data={chartData} label="Monthly volume" />
const chartData = [
    { label: "Jan", value: 24, color: "#2f80ed" },
    { label: "Feb", value: 38, color: "#27ae60" },
    { label: "Mar", value: 31, color: "#f2994a" },
    { label: "Apr", value: 47, color: "#9b51e0" },
  ]; 
  
  
  <BarChart state="info" data={chartData} label="Monthly volume" />

Interaction states

Loading
Monthly volume
interaction-states.tsx
// Loading
const chartData = [
    { label: "Jan", value: 24, color: "#2f80ed" },
    { label: "Feb", value: 38, color: "#27ae60" },
    { label: "Mar", value: 31, color: "#f2994a" },
    { label: "Apr", value: 47, color: "#9b51e0" },
  ]; 
  
  
  <BarChart loading data={chartData} label="Monthly volume" />

Props API

17 props
Columns
Bar Chart props API
Default
Description
aria-labelstringNoaria—Accessible label for the chart graphic.
classNamestringNostyling—Additional class name for the root.
dataChartDatum[]Yesprops—Labelled values rendered as vertical bars.
data-testidstringNotesting—Backward-compatible alias for test ID attributes.
gapnumberNoprops8Gap between bars in SVG units.
heightnumberNoprops180Height of the SVG viewport.
labelReactNodeNoprops—Visible chart label.
loadingbooleanNopropsfalseWhether the component should display a loading state.
paddingnumberNoprops24Inner SVG padding.
showGridbooleanNopropstrueWhether to render horizontal guide lines.
showLabelsbooleanNopropstrueWhether to render category labels below bars.
stateStateTypeNostyling—Visual state class used for styling.