Segmented Bar
A card with a proportion bar: pill segments on a hatched remainder, a headline figure, hover values and a legend. Colors are a CVD-validated categorical set.
Interactive preview · desktop · dark
Installation
Installation is available on the Startup and Business plans. Your personal install command appears here once you have access.
Usage
Import it, pass your props, and make it part of your product.
example.tsx
import { HardDrive } from 'lucide-react';import { SegmentedBar } from '@/components/component-kit/items/chart-segmented-bar';
export function Example() { return ( <SegmentedBar icon={HardDrive} title="Storage" aria-label="Storage by type" total={512} segments={[ { id: 'photos', label: 'Photos', value: 212 }, { id: 'video', label: 'Video', value: 96 }, { id: 'docs', label: 'Documents', value: 41 }, ]} format={(gb) => `${gb} GB`} /> );}Props
| Prop | Type | Default | Description |
|---|---|---|---|
segments | SegmentedBarSegment[] | — | Segments with id, label, value and optional light/dark color. |
title | ReactNode | — | Card title. Omit to render the bare track. |
summaryLabel | ReactNode | Used | Label above the headline figure. |
total | number | sum of segments | Denominator; the remainder stays hatched. |
thickness | 8 | 10 | 12 | 10 | Track height in pixels. |
showLegend | boolean | true | Show labels and values under the track. |