Skip to main content
PercentageBarChart
@coinbase/cds-web-visualization@3.6.0
A bar chart component for comparing share or mix across categories as percentages. Supports horizontal and vertical orientations, 100% stacked bars, and a fixed 0–100% value axis.
import { PercentageBarChart } from '@coinbase/cds-web-visualization'
Peer dependencies
  • framer-motion: ^10.18.0
Related components

PercentageBarChart is a wrapper for BarChart that simplifies the creation of segmented, part-to-whole horizontal visualizations. Charts are built using SVGs.

Basics

The only prop required is series, which takes an array of series objects. Each series object needs an id and a value for data.

Loading...

Stack Gap

Use stackGap to add space between segments while keeping the full bar length.

Loading...

Border Radius

Bars use borderRadius like in BarChart.

Loading...

Data

Negative values, null, and missing indices from a shorter data array are treated as zero for that segment at that category. A single-number data value applies to the first category only—later categories count as zero for that series.

Loading...

If every group sums to zero after clamping, nothing is drawn—handle that in surrounding UI (empty state or copy).

Customization

Bar Stack Spacing

Use categoryPadding on the band axis to adjust spacing between stacks.

Loading...

Minimum Bar Size

barMinSize enforces a minimum pixel size for individual segments (non-zero values), similar to BarChart. Use it when a small share would otherwise be too narrow to see or interact with:

Loading...

Custom Components

Slanted Stack Gap

A custom BarComponent that replaces the default rectangular inner edges with slanted cuts, creating a parallelogram-shaped gap purely from the path geometry—no stackGap needed. Outer ends stay pill-shaped.

Loading...

Dotted bar

A custom BarComponent can render a dotted fill (SVG pattern mask plus outline). Set BarComponent on one series to emphasize a single segment, or on the chart to apply the same look to every segment.

Loading...

Animations

Configure motion with the transitions prop (forwarded to BarChart). Toggle motion with animate.

Loading...

Composed Examples

Live-updating Data

Using a custom legend, you can create a prediction markets-style chart that stays in sync when data changes.

Loading...

Vertical Mix

Monthly BTC / ETH / Other portfolio allocation across a full year, with layout="vertical" and the legend on the right.

Loading...

Buy vs Sell

You can combine a PercentageBarChart with a custom legend to create a buy vs sell chart.

Loading...

Is this page useful?

Coinbase Design is an open-source, adaptable system of guidelines, components, and tools that aid the best practices of user interface design for crypto products.