Ballmac UI home

Split Bar

New

One bar cut into shares with a legend that says the same in numbers. Pointing at a legend row lights its slice and dims the rest, and choosing it keeps it lit.

v1.0.0Updated Oct 25, 2026Ships with a test
What changed

Where the spend goes

$15,760

Installation

$ pnpm dlx shadcn@latest add @ballmac/split-bar

Usage

import { SplitBar } from "@/components/ballmac/split-bar"

The full example is in the Code tab above.

Examples

Two shares

Traffic

API reference

PropTypeDefault
segments*SplitSegment[]—
titlestring—
format

Formats each value.

(value: number) => string(v) => nf.format(v)
total

Shows a total above the bar.

string—

Also accepts the standard attributes of its root element.

Accessibility

KeyAction
LegendThe accessible version: buttons with label, value and percent; pressed state
BarDecoration only
ColorNever the only way to tell parts apart

Use with AI

segments is [{ id, label, value, hint? }]; title, total (text above the bar), format(value). The legend lists every segment with its value and percent; hover or focus lights a slice, and a click keeps it lit (aria-pressed). With the shadcn MCP server set up (guide), ask your agent:

Add the Ballmac UI Split Bar (@ballmac/split-bar) to this project with the shadcn MCP, then use it where it fits.

Use it for

  • Breaking a total into a handful of parts
  • Spend, storage, traffic or time splits

Not for

  • Many parts or nested parts; use treemap
  • Ranking; use bar-list

Registry JSON: https://ui.ballmac.com/r/split-bar.json

Credits

Free to use in personal and commercial projects.

npm
None

Ballmac UI Pro

Need the whole screen, not one piece?

150 premium blocks (dashboards, settings, calendars, mail, shops, onboarding), a private shadcn registry and Figma tokens. Blocks that show data come with loading, empty and error states built in.

Not ready? Try three Pro blocks free

Leave your email and the blocks appear right here, ready to copy. Yours to use in any project.