MeterGroup

A segmented horizontal bar that visualises proportions within a total. Each segment represents a category, sized by its value. Pair it with MeterGroupLegend to show labels and values.

Use non-negative segment values and a positive total. In 0.0.34, max below the sum does not clamp segment proportions; it only removes the remainder. Size is captured at initialization (small wins over compact); legend orientation is also captured. Choose these before mounting. MeterGroup forwards extra HTML attributes, while MeterGroupLegend does not. Built-in click handlers are pointer-only; provide real buttons in custom legend content for keyboard selection.


Basic Usage

Pass an array of MeterItem objects. The bar fills to the sum of all values — no max needed.

  • Documents 25
  • Photos 40
  • Apps 15
  • Other 10

Explicit Max

Set max to show a fixed total. Values below max render the remaining space in a neutral fill. The value snippet in MeterGroupLegend lets you add a custom suffix.

Storage (100 GB total) 65 / 100 GB
  • Used 45 GB
  • Reserved 20 GB

Click Events

Use onsegmentclick and onitemclick to respond to interaction. Both receive the full MeterItem object.

Click a segment to select it.

  • Design 35%
  • Development 50%
  • Testing 15%

Vertical

Add the vertical prop to both components. Set a height on MeterGroup via class; the legend stacks its items with values aligned to the right.

  • Q1 32
  • Q2 28
  • Q3 22
  • Q4 18

Sizes

Use compact or small to reduce the bar thickness and legend text size.

Normal

  • Alpha 45
  • Beta 30
  • Gamma 25

Compact

  • Alpha 45
  • Beta 30
  • Gamma 25

Small

  • Alpha 45
  • Beta 30
  • Gamma 25

Segment content and custom legend items

The segment snippet renders inside each proportional segment. The legend item snippet replaces its swatch, label and value content, but not the li wrapper. With this override, showValues and the value snippet no longer control the content. A real button provides explicit keyboard activation.

30%
50%
20%

Selected: None