Meter group
vig-meter-group
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.
- 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.
- Documents18.5 GB
- Media52 GB
- Backups30 GB
- 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"]
| Part | Element | data-state |
|---|---|---|
label | aria-labelledby ). | — |
track | role="meter" bar. | — |
segment | — | |
remainder | max . | — |
legend | <ul> legend. | — |
legend-item | — | |
swatch | — | |
legend-label | — | |
legend-value | — |
Accessibility
- The bar is one
role="meter"named bylabel(keep it withhideLabelfor screen readers only). Its value is the sum of the segments and itsaria-valuetextlists every segment and the total ("Apps: 16%, Photos: 24%, …, total 61% of 100%",labels.totalLabelfor 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
patternsmatches segments to legend entries by shape too. A rebranded--color-primarymust 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-groupSeveral 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.
| Name | Type | Default | Description |
|---|---|---|---|
formatValue | ((value: number, max: number) => string) | undefined | undefined | Text of a value in the legend and in |
hideLabel | boolean | false | Keeps the label for screen readers only. |
label | string | — | Names the meter; shown above the bar unless |
labels | Partial<MeterGroupLabels> | — | Texts (i18n); locale defaults. |
legend | MeterGroupLegend | 'end' | Legend above ( |
max | number | undefined | 100 | The value of a full bar; segments past it are cut off. Default 100. |
patterns | boolean | false | Draws a pattern over each segment and swatch (stripes, hatching), so segments and their legend entries match by shape, not by hue alone. |
size | MeterGroupSize | 'md' | Bar thickness; it scales with the font. |
values | readonly MeterGroupValue[] | [] | The segments, in order along the bar. |