This page as markdown: /segmented-bar.md · Index for agents: /llms.txt · Everything in one file: /llms-full.txt

SegmentedBar

Status: stable

One bar split into the parts of a whole — revenue by type, storage by kind, results by outcome. Segments size by their share of the total; the bar is one labelled image to assistive tech.

Keywords: breakdown, stacked, segmented, proportion, split, distribution, category, bar, share

Usage

Use SegmentedBar when a stat card or row needs to show how a total divides into a few categories. Pair it with a legend you compose (StatusDot + label + share), placed where the card has room. For one reading against a range (storage used, quota), use Meter; for task completion, use Progress.

Best practices

Anatomy

Part Required Description
Track yes The rounded bar; segments fill it edge to edge with a hairline gap.
Segment yes One category, sized by its share of the total and filled with its tone.

Props

Name Type Default Description
segments { label: string; value: number; tone?: SegmentedBarTone }[] — The categories, left to right. Values in any unit; zero or negative values are skipped.
label string — What the bar breaks down. Prefixes the accessible summary of every segment's share.
size "sm" | "md" | "lg" "md" Bar thickness — the same rails as Meter and Progress.
locale string runtime locale Locale for the spoken percentages.

Variants

Tokens used

tone-1, tone-2, tone-3, tone-info, primary, muted-foreground, success, tone-warning, destructive, destructive-mark, success-mark, tone-warning-mark, tone-info-mark, tone-1-mark, tone-2-mark, tone-3-mark

Motion

Accessibility

Related

Examples

With a legend

import { SegmentedBar, Stack, StatusDot } from "@sableui/react"

const sales = [
	{ label: "Direct", value: 42, tone: "1" },
	{ label: "Partners", value: 27, tone: "2" },
	{ label: "Referrals", value: 19, tone: "3" },
] as const

<Stack gap={3}>
	<SegmentedBar label="Revenue by channel" segments={[...sales]} size="lg" />
	<ul className="flex flex-col gap-1.5">
		{sales.map((s) => (
			<li key={s.label} className="flex items-center gap-2 text-body-sm">
				<StatusDot tone={s.tone} />
				<span className="flex-1 text-muted-foreground">{s.label}</span>
				<span className="text-mono-caption">{s.value}%</span>
			</li>
		))}
	</ul>
</Stack>

Test results — status tones

import { SegmentedBar } from "@sableui/react"

<SegmentedBar
	label="Test results"
	segments={[
		{ label: "Passed", value: 412, tone: "success" },
		{ label: "Flaky", value: 9, tone: "warning" },
		{ label: "Failed", value: 3, tone: "destructive" },
	]}
/>