Meter group

Several values in one bar, such as the parts of a storage quota, with a legend of labels and values.

  • vig-meter-group
Import
import { MeterGroup } from '@vigdx/ui/meter-group';

Basic

values is a list of { label, value, color? } ; max (default 100) is a full bar. The legend shows each value as a percentage of max , formatted for the active locale.

Storage
  • Apps16%
  • Photos24%
  • Messages9%
  • System12%

Units, colors and legend

formatValue is a function of the value and max for the legend and the screen-reader text. color takes a theme color name ( primary , secondary , info , success , warning , error , accent ); without it the segments take METER_GROUP_PALETTE in order. An unknown name falls back to the palette with a dev-mode warning. patterns adds a pattern (stripes, hatching) to each segment and its swatch, so they match by shape too. legend is end (below), start (above) or none ; size sets the bar thickness, which follows the font. Values past max are cut off in the bar; the legend and the screen-reader text keep the real numbers. The bar shares its width, less the 2px gaps, in proportion to the values and draws every non-zero segment at least 2px wide, so very small values are approximated: the legend gives them exactly.

Storage (128 GB)
  • Documents18.5 GB
  • Media52 GB
  • Backups30 GB
Support tickets
  • Resolved52%
  • Waiting23%
  • Escalated8%
  • New17%

Styling hooks

Internal elements carry a stable data-part and the component's data-scope; both are public API, so removing one is a breaking change. Select a part by both, e.g. [data-scope="meter-group"][data-part="label"] { … }: the pair stays within this component when kit components nest, and also reaches parts in overlay panels, which render outside the host. State is exposed through aria-* and, where listed, a data-state; literal values are checked by the API gate, values computed from the component's state follow its documented types. Other data-* attributes listed below (such as data-opening while an overlay animates) are API too. See Customizing.

Scope: [data-scope="meter-group"]

MeterGroup styling hooks
Part Element data-state
label The label naming the meter ( aria-labelledby ). —
track The role="meter" bar. —
segment One value in the bar (at least 2px wide). —
remainder The unused rest of the bar, up to max . —
legend The <ul> legend. —
legend-item One legend entry. —
swatch The color (or forced-colors pattern) of an entry. —
legend-label The label of an entry. —
legend-value The formatted value of an entry. —

Accessibility

  • The bar is one role="meter" named by label (keep it with hideLabel for screen readers only). Its value is the sum of the segments and its aria-valuetext lists every segment and the total ("Apps: 16%, Photos: 24%, …, total 61% of 100%", labels.totalLabel for the total, labels.segmentLabel), so a screen reader that lands on the meter hears all parts at once. One meter per segment would be announced as unrelated meters, with no names of their own in some screen readers; the visible legend repeats the parts as a plain list that every screen reader reads.
  • Segment colors are theme tokens that hold 3:1 against the page in the kit's light and dark palettes. A 2px gap shows the page between segments, so neighbours need contrast with the page, not with each other; the legend gives every value in text, so color is never the only cue, and patterns matches segments to legend entries by shape too. A rebranded --color-primary must keep 3:1 against the background for this to hold.
  • Forced-colors mode replaces the colors with six system-color patterns, one per palette color (solid, diagonal, vertical, horizontal and reverse diagonal stripes, cross-hatching), drawn in the bar and the legend swatches alike, and outlines the bar.

API

MeterGroup

vig-meter-group component

Several values in one bar, such as the parts of a storage quota, with a legend of labels and values.

Example :
<vig-meter-group label="Storage" [values]="usage" />

The bar is one role="meter" named by label: its value is the sum of the segments and its aria-valuetext lists every segment and the total ("Apps: 20%, Photos: 35%, total 55% of 100%"), so a screen reader that reaches the meter hears all parts at once. The legend repeats them as a visible list. Segment colors are theme tokens (color, or METER_GROUP_PALETTE in order); a 2px gap separates neighbours, so each segment needs contrast with the page only, not with the next one. The bar shares its width, less the gaps, in proportion to the values, and draws every non-zero segment at least 2px wide, so tiny values are approximated. Forced-colors mode draws a pattern per segment; patterns draws them in normal mode too.

MeterGroup props
Name Type Default Description
formatValue((value: number, max: number) => string) | undefinedundefined

Text of a value in the legend and in aria-valuetext, e.g. (value) => value + ' GB'; the share of max as a locale percentage by default.

hideLabelbooleanfalse

Keeps the label for screen readers only.

label required string—

Names the meter; shown above the bar unless hideLabel.

labelsPartial<MeterGroupLabels>—

Texts (i18n); locale defaults.

legendMeterGroupLegend'end'

Legend above (start) or below (end) the bar, or none.

maxnumber | undefined100

The value of a full bar; segments past it are cut off. Default 100.

patternsbooleanfalse

Draws a pattern over each segment and swatch (stripes, hatching), so segments and their legend entries match by shape, not by hue alone.

sizeMeterGroupSize'md'

Bar thickness; it scales with the font.

valuesreadonly MeterGroupValue[][]

The segments, in order along the bar.

Are you sure?