Segmented Bar

Parts of one whole in one bar with a legend: each segment is as wide as its share and coloured by a tone. A thin bar for cards and table rows, a tall one with the percent inside each segment.

Part of @tectra-ng/charts (npm install @tectra-ng/charts, also included in tectra-ng).

Features8APIThemingAccessibility

Basic

Pass items with a key, a label, a value and a tone. The parts keep their order; hover a segment to see its label and value.

Paid42Pending13Overdue5

Tones

Seven tones: primary (default), secondary (the primary colour mixed into the card), success, info, warn, danger and neutral. They follow the theme, the primary colour and dark mode.

PrimarySecondarySuccessInfoWarnDangerNeutral

Large

size="large" draws a tall bar with the percent inside each segment and a bigger legend.

Media48Documents22Backups18Free12

Legend

showValue, showPercent and hideEmptyInLegend choose what the legend lists; monoLabels writes codes in the monospace font. Without a legend (showLegend off) the bar itself is read by screen readers with every part.

2xx18,42086.6%3xx2,21010.4%4xx6403%5xx00%

Aside

Content projected into the bar sits at the end of the legend row: a total, a period or a link.

Done24In review6To do939 tasks

Value format

valueFormat formats the values in the legend and the segment titles: number (default), integer, compact, percent or your own function.

Hosting$1,84054.6%Tools$92027.3%Ads$61018.1%

Design tokens

dt sets the tokens of one bar — the segmentedBar group of the chart tokens: heights, gaps, radii and the colour of each tone.

Team64Pro28Free40

Pass through

pt adds classes and styles to the parts: root, track, segment, legend, legendItem, dot, label, value, percent, aside.

Desktop58Mobile36Tablet6