Components
Segment Bar
Each segment is its own rounded block, sized by its share. The featured segment prints its value inside its block and gets a pill in the legend.
Installation
bunx @happlyui/cli@latest add segment-bar
Dependencies
Registry dependencies
These are automatically installed when you add this component.
happly-ui-utils
Usage
import * as SegmentBar from "@/components/ui/segment-bar"
<SegmentBar.Root
items={[{ label: "Category A", value: 13 }]}
highlighted="Category A"
/>
Examples
Default
A label-only legend split into two columns.
Card title
- Category A: 13
- Category B: 9
- Category C: 7
- Category D: 6
- Category E: 5
<SegmentBar.Root items={items} highlighted="Category A" />
Rows legend
A full-width legend with each count on the right.
Card title
- Category A13
- Category B9
- Category C7
- Category D6
- Category E5
<SegmentBar.Root items={items} highlighted="Category B" legend="rows" />
API Reference
SegmentBar.Root
The blocks and their legend. Colours follow item order through the five-step chart ramp.
| Prop | Type | Default | Description |
|---|---|---|---|
items | { label: string; value: number }[] | - | Segments left to right, in the order given |
highlighted | string | null | - | Label of the segment to feature. Omitted or null features none |
legend | 'columns' | 'rows' | 'columns' | Two label-only columns, or rows with counts |