Meter
VMeter shows a reading within a known range, such as disk usage, a battery level or the strength of a password. Its colour can say whether the reading is good, average or poor.
Usage
Examples
Regions
low, high and optimum follow the rules of the native <meter>. The part of the range holding optimum is good and painted in success, the part next to it is average in warning, and the far part is poor in danger. Without any of the three, the meter is in the accent colour.
Tones
tone fixes the colour whatever the region. color takes a colour of your own, and the track is derived from it.
Value
The value is a percentage of the range by default. formatOptions formats the value itself for the current locale, and valueText replaces it with your own words. Screen readers read the same text.
Segments
segments splits the bar into equal parts. Colour alone does not tell the region apart: say it in valueText when it matters.
Sizes
size sets the thickness of the bar, 4, 8 or 12 pixels. The meter takes the whole width of its container.
Hidden text
hideLabel and hideValue remove the text above the bar. Screen readers still hear the label and the value.
API
Props
| Prop | Type | Default |
|---|---|---|
value | number | 0 |
| Reading, brought back into the range. | ||
min | number | 0 |
| Lower bound of the range. | ||
max | number | 100 |
| Upper bound of the range. | ||
low | number | none |
| Upper end of the low part of the range. | ||
high | number | none |
| Lower end of the high part of the range. | ||
optimum | number | none |
| Best value. Its part of the range is good, the next one average and the far one poor. | ||
label | string | none |
| What is measured, shown above the bar and naming it. Uses the dictionary by default; ARIA naming attributes take precedence. | ||
hideLabel | boolean | false |
| Hides the label visually. Screen readers still read it. | ||
valueText | string | none |
| Text replacing the formatted value, on screen and for screen readers. | ||
formatOptions | Intl.NumberFormatOptions | none |
Intl.NumberFormat options formatting the value itself. | ||
hideValue | boolean | false |
| Hides the value visually. Screen readers still read it. | ||
tone | MeterTone'accent' | 'neutral' | 'success' | 'warning' | 'danger' | none |
Colour of the fill. Chosen from the region when low, high or optimum is set, accent otherwise. | ||
color | string | none |
| Custom CSS colour replacing the tone. | ||
segments | number | 1 |
| Number of equal parts the bar is split into. | ||
size | MeterSize'sm' | 'md' | 'lg' | 'md' |
| Thickness of the bar and size of the text. | ||
CSS variables
| Token | Value |
|---|---|
--vectis-control-size-meter-thickness-sm | 0.25rem |
--vectis-control-size-meter-thickness-md | 0.5rem |
--vectis-control-size-meter-thickness-lg | 0.75rem |
--vectis-control-size-meter-segment-gap | 0.125rem |