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
showValue writes the value after the label. It 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, written or not.
Value position
valuePosition writes the value inside the bar, at its start, centre or end, as in VProgressLinear. Only size="xl" is thick enough to hold it.
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, from 2 to 20 pixels, on the same scale as VProgressLinear. The meter takes the whole width of its container.
Orientation
orientation="vertical" fills from the bottom up, segments and text inside the bar included. Set a height to control the bar’s length.
Hidden text
Without showValue, the value is not written, and hideLabel hides the label. Screen readers still hear both.
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. | ||
showValue | boolean | false |
| Writes the value. Screen readers read it either way. | ||
valuePosition | MeterValuePosition'header' | 'start' | 'center' | 'end' | 'header' |
| Value position: after the label, or inside the bar. Vertical start is the bottom. | ||
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'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'md' |
Bar thickness. Only xl holds the value inside the bar. | ||
orientation | MeterOrientation'horizontal' | 'vertical' | 'horizontal' |
| Horizontal or vertical bar. Vertical fills from bottom to top. | ||
CSS variables
| Token | Value |
|---|---|
--vectis-control-size-bar-thickness-xs | 0.125rem |
--vectis-control-size-bar-thickness-sm | 0.25rem |
--vectis-control-size-bar-thickness-md | 0.5rem |
--vectis-control-size-bar-thickness-lg | 0.75rem |
--vectis-control-size-bar-thickness-xl | 1.25rem |
--vectis-control-size-bar-length | 10rem |
--vectis-control-size-meter-segment-gap | 0.125rem |