Meter is used to represent an available quantity or allotment of a measurable unit.
Overview
Meter can be used to display the amount of a resource remaining, or yet to be used. It can represent the quantity of resource consumed as a value, in relation to min and max limits, and optionally display low and high quantity thresholds to a user.
Meter can also be used to display a count or quantity anytime max is a known value. For instance, Meter is an appropriate way of displaying the number of days in a year that precipitation has been recorded.
Sample
Usage
- Display the remaining number of credits or other resource available
- Display the amount of storage used on a hard drive
- Communicate significant quantity thresholds that could impact a user's experience
- Display a count or quantity accrued towards
max
Component comparison
While visually similar to Progress, Meter has distinct capabilities and intended use cases.
value can be set, and it is always a percentage between 0 and 100.Best Practices
Recommendations
Fill types
Use the appropriate fill. The default, "range", is useful for providing context about the importance of the current value, for instance if a user is approaching the limit of their available storage. Use "single" when there is no inherent benefit or detriment to the current value.
fillType of "range" when the quantity or allotment could become scarce and negatively impact a user.fillType of "single" when the current quantity or allotment is strictly informative and has no positive or negative bearing on the user.Range bounds with low and high
It is recommended to use low and/or high when they represent quantities of significance. For instance, if the value exceeds high, it may be useful to display corresponding messaging in a Notice, or otherwise communicate the significance to the user.
Once a range threshold is surpassed by the component's value, it is automatically hidden.
Label types
The value and range properties can be configured as "units" or "percent". The former can be useful when displaying explicit quantities to a user. The latter is often used to simplify complex or lengthy numbers.
It can be valid to use a combination of values, for instance setting range as "percent" and the value as "units".
When using value or range as "units", it may be useful to use the unit property to provide additional context to a user.
valueLabelType or rangeLabelType of "units", when knowing the explicit number may benefit a user.valueLabelType or rangeLabelType of "percent" when the numbers are long, or the exact numeric value is not important to a user.Ensure the unit is concise and provides meaningful context to the user.
unitLabel.unitLabel.API reference
Properties
| Property | Attribute | Description | Type | Default |
|---|---|---|---|---|
| appearance | appearance | Specifies the appearance of the component. | Extract<"outline" | "outline-fill" | "solid", Appearance> | "outline-fill" |
| disabled | disabled | When | boolean | false |
| fillType | fill-type | Specifies the component's display.
| MeterFillType | "range" |
| form | form | Specifies the | string | undefined | |
| groupSeparator | group-separator | When | boolean | false |
| high | high | Specifies a high value. When | number | undefined | |
| label | label | Specifies an accessible label for the component. | string | |
| low | low | Specifies a low value. When | number | undefined | |
| max | max | Specifies the component's highest allowed value. | number | 100 |
| min | min | Specifies the component's lowest allowed value. | number | 0 |
| name | name | Specifies the name of the component. Required to pass the component's | string | undefined | |
| numberingSystem | numbering-system | Specifies the Unicode numeral system used by the component for localization. | NumberingSystem | undefined | |
| rangeLabels | range-labels | When | boolean | false |
| rangeLabelType | range-label-type | When | MeterLabelType | "percent" |
| scale | scale | Specifies the size of the component. | Scale | "m" |
| unitLabel | unit-label | When | string | "" |
| value | value | Specifies the component's value. | number | undefined | |
| valueLabel | value-label | When | boolean | false |
| valueLabelType | value-label-type | When | MeterLabelType | "percent" |
Styles
| Name | Description |
|---|---|
| --calcite-meter-background-color | Specifies the background color of the component. |
| --calcite-meter-border-color | Specifies the border color of the component and displayed step lines. |
| --calcite-meter-shadow | Specifies the box shadow of the component. |
| --calcite-meter-corner-radius | Specifies the corner radius of the component. |
| --calcite-meter-fill-color | Specifies the color of the component's fill. |
| --calcite-meter-range-text-color | Specifies the color of the component's range labels. |
| --calcite-meter-value-text-color | Specifies the color of the component's value label. |
Methods
| Name | Description | Signature |
|---|---|---|
| componentOnReady | Creates a promise that resolves once the component is fully loaded. | componentOnReady(): Promise<this> |