Docs/Cartesian Components/Bar

Bar

Bar is a graphical series component that renders bars on a cartesian chart (typically a BarChart). Bars can be stacked, sized, styled, and rendered with custom shapes.

import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip } from "solid-recharts";

<BarChart width={500} height={300} data={data}>
  <CartesianGrid strokeDasharray="3 3" />
  <XAxis dataKey="name" />
  <YAxis />
  <Tooltip />
  <Bar dataKey="value" fill="#8884d8" />
</BarChart>;
BarChart
bar-basic.tsxOpen ↗
Loading source...

Props

PropTypeDefaultDescription
dataKeystring | number | func—Data key or accessor for the bar's values
fillstring"#3182bd"Bar fill color
fillOpacitynumber | string1Fill transparency (0–1)
strokestring—Bar outline color
strokeWidthnumber0Outline thickness
stackIdstring—Stack bars with others sharing this id
barSizenumber—Fixed bar width (pixels); auto-sized if omitted
radiusnumber | [tl, tr, br, bl]0Corner radius of bars
minPointSizenumber | "auto"0Minimum bar height (filters tiny bars)
backgroundboolean | objectfalseRender full-span background behind each bar
labelboolean | objectfalseRender labels on bars
isAnimationActiveboolean | "auto""auto"Enable enter/update animation

See the recharts Bar docs for the full prop matrix.

Notes

  • Stacking: pass the same stackId to multiple Bar components to stack them (bars with different stack ids group side-by-side).
  • Radius: pass a single number for uniform corners, or [topLeft, topRight, bottomRight, bottomLeft] for per-corner control.
  • Custom shapes: pass a function as shape to render custom bar geometry; it receives the bar's rectangle + payload.
  • Backgrounds: set background={true} or background={{}} to render a full-height background behind each bar for a grouped effect.

See also

  • BarChart — the chart container
  • Area — alternative stacking with areas
  • Cell — per-bar fill/stroke overrides
  • XAxis · YAxis — axes