UIComponentsReact
Several measurements stacked on one bar, such as storage used by kind, with a legend that names each one.
Built on the headless Meter Group.See its API in Docs
Rendered by React 19.3.1
Installation
npx shadcn@4.23.0 add https://hamur.dev/r/react/meter-group.jsonIt also adds utils. The app needs its setup first: Installation.
Usage
Pass value, an array of amounts out of max (100 by default). MeterGroup renders only its children: a MeterGroupLabel names the group, MeterGroupValue shows the total, a MeterGroupTrack holds one MeterGroupIndicator per value, and one MeterGroupItem per value, with a MeterGroupItemLabel and a MeterGroupItemValue, is the legend. Indicator and Item take the index of their value. Each Item is a meter that screen readers reach; the segments are drawn only, so keep one Item per value, visually hidden where no legend shows. When the total passes max, the segments keep their proportions and every part gets data-overflow. The roles and values come from the headless Meter Group. For one value, use the Meter.
import {
MeterGroup,
MeterGroupIndicator,
MeterGroupItem,
MeterGroupItemLabel,
MeterGroupItemValue,
MeterGroupLabel,
MeterGroupTrack,
MeterGroupValue,
} from '@/components/ui/meter-group'Examples
Default
Storage used by apps, photos and the system, with the total and legend.
Segments and legend dots take the primary colour, fading by data-index; colour a value with className on its Indicator and Item. The name and value of each segment are text in its Item, not colour alone (WCAG 1.4.1), adjacent segments are parted by a 2 px gap (1.4.11), and under forced colours, where backgrounds are not drawn, the segments and dots are outlined. This item takes Base UI's component ID as its slug.
API reference
The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Meter Group's API reference.