UnflowUI
Components

ShareBar

A horizontal 100% stacked bar with legend chips, for how a total splits across a few parts.

Overview

ShareBar shows how a total divides across a handful of parts, such as spend by channel or seats by team. Each part gets a segment sized by its share and a legend chip with its label, percentage and value. Use Chart with type="donut" when the parts need more room, or when a tooltip helps.

Negative values count as zero, and parts with no value get no segment. When the total is zero, ShareBar shows an empty state.

Import

import { ShareBar } from '@unflowio/ui/components/ShareBar';

Props

PropTypeDefaultDescription
labelstring—Required. Accessible name of the bar (e.g. "Spend by channel")
itemsShareBarItem[]—Required. One segment per item, in order
valueFormatIntl.NumberFormatOptions—Formats item values, e.g. { style: 'currency', currency: 'EUR' }
formatValue(value: number) => string—Formats every value instead of valueFormat
legendbooleantrueShows the legend chips. When off, the same text stays available to screen readers
emptyStateReactNode—Rendered instead of the default StateMessage when the total is zero

ShareBarItem

FieldTypeDescription
labelstringRequired. Part name
valuenumberRequired. Part value. Negative values count as zero
colorChartColorDefaults to chart-1 to chart-6 by position. Takes the same values as Chart colors

Basic usage

  • Web49%€1,042.30
  • Mobile18%€388.10
  • API24%€512.40
  • Email9%€197.80
<ShareBar
  label="Spend by channel"
  items={[
    { label: 'Web', value: 1042.3 },
    { label: 'Mobile', value: 388.1 },
    { label: 'API', value: 512.4 },
    { label: 'Email', value: 197.8 },
  ]}
  valueFormat={{ style: 'currency', currency: 'EUR' }}
/>

Colors

Each item can set its own color: a chart token, accent, fg, muted, a CSS custom property or any CSS color.

  • Paid68%64
  • Trial19%18
  • Invited13%12
<ShareBar
  label="Seats by plan"
  items={[
    { label: 'Paid', value: 64, color: 'accent' },
    { label: 'Trial', value: 18, color: 'muted' },
    { label: 'Invited', value: 12, color: '--info' },
  ]}
/>

Bar only

Set legend={false} where space is tight, e.g. in a table cell. The legend text stays available to screen readers.

  • Web49%1,042.3
  • Mobile18%388.1
  • API24%512.4
  • Email9%197.8
<ShareBar label="Spend by channel" items={items} legend={false} />

Accessibility

  • Renders a figure named by label.
  • The legend is a list in which each part reads as its label, share and formatted value. With legend={false}, the list is visually hidden but still read.
  • Segments are decorative. Parts are told apart by their legend text, not by color alone.