TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/recharts/recharts/llms.txt
Use this file to discover all available pages before exploring further.
BarStack component allows you to group multiple Bar components together to create stacked bar charts with unified styling. It’s particularly useful for applying rounded corners to an entire stack as if it were a single bar.
Import
Basic usage
Props
Unique identifier for the stack. When two Bars have the same
stackId, they are stacked together in the chart.- If undefined, a unique ID is generated automatically
- When both BarStack and individual Bar components have
stackIddefined, the BarStack’sstackIdtakes precedence
Border radius for the entire stack. Applies rounded corners to the outer edges of the complete stack, not individual bars.
- Single number: Applies to all four corners
- Array of four numbers:
[topLeft, topRight, bottomRight, bottomLeft]
Bar components to be stacked together. Typically multiple
<Bar> components.Examples
Stacked bars with rounded corners
Apply rounded corners to the entire stack:The
radius prop rounds only the outer corners of the entire stack. Middle bars will have square corners where they meet other bars in the stack.Combining stack radius with individual bar radius
For the best visual effect, combineBarStack.radius with individual Bar.radius:
Multiple stacks with different IDs
Create multiple independent stacks by providing differentstackId values:
How it works
BarStack creates a React context that:- Manages stack identity: All Bar components inside a BarStack share the same
stackId, causing them to stack vertically (or horizontally in vertical layout) - Applies unified radius: Creates SVG clip paths to round the outer corners of the entire stack as a single unit
- Overrides individual stackIds: If a Bar component has its own
stackId, the BarStack’sstackIdtakes precedence
Notes
BarStack was introduced in Recharts 3.6 to provide better control over stacked bar styling.