Sophic Interface Systems
Components

Stacked Bar

One bar split into shares of one hue, fading from the largest, with a legend, for a mix such as an asset allocation.

  • Cash equivalents39.90%
  • Equity35.70%
  • Fixed income24.40%

A single bar split into segments, one per share of a whole, in one hue that fades from the largest share to the smallest, with a legend that pairs each shade with its label and value. Use it when the shares add up to one total, such as the asset classes in a portfolio. For one share against the rest, use Progress Bar.

Usage

import { StackedBar, StackedBarLegend } from "@sophic/portal-ui";

const segments = [
  { key: "cash", label: "Cash equivalents", percent: 39.9 },
  { key: "equity", label: "Equity", percent: 35.7 },
  { key: "fixed-income", label: "Fixed income", percent: 24.4 },
];

<StackedBar segments={segments} />
<StackedBarLegend
  segments={segments}
  renderValue={(segment) => `${segment.percent}%`}
/>;

Pass the same segments array to both pieces, sorted largest first: shades follow the position in the array, so the first is the deepest and the bar and the legend always match. Segments share the bar in proportion to percent. A zero or negative segment is left out of the bar; any other segment keeps a visible minimum width.

Under a figure that already carries the total, such as a balance row, pass size="sm" to StackedBarLegend: subline text and tight rows, so the legend supports the figure instead of competing with it.

Available€20,394.30
  • Free cash€2,043.00
  • Holdings€18,351.30

The bar is announced as an image. Its default label lists each visible segment with its percent; pass aria-label to override it. The legend is a list, and renderValue decides the text on the right, so it can be formatted or hidden.

Props

Prop

Type

Default

StackedBarLegend

Prop

Type

Default

StackedBarSegment

Prop

Type

Default

Changelog

  • 2 December 2026: Segments take an optional tone (1 to 7), a fixed ramp step, so a category keeps its shade in every chart. Full notes
  • 24 November 2026: New component for one bar split into shares of one hue, fading from the largest, with a legend. Full notes
  • 24 November 2026: StackedBarLegend takes size="sm": subline text and tight rows, for a legend under a figure that carries the total. Full notes

On this page