Meter
A measurement inside a known range — storage, quota, strength — with native meter thresholds and an optional segmented breakdown.
Attributes
| Name | Type | Default | Description |
|---|---|---|---|
value | number | 0 | The measurement, between min and max. Ignored when segments are set. |
min | number | 0 | Lower end of the range. |
max | number | 100 | Upper end of the range. |
low | number | undefined | undefined | Upper end of the low region, as in the native <meter>. |
high | number | undefined | undefined | Lower end of the high region, as in the native <meter>. |
optimum | number | undefined | undefined | The best value. Below low it makes low values optimum and high ones critical (a fuel gauge reads the other
way: optimum above high); between them the middle region is optimum and both ends sub-optimum. |
segments | MeterSegment[] | [] | Parts of a segmented meter, { label, value, color? }, in range units. Accepts a JSON string as an attribute. |
label | string | — | Label when the default slot is empty. |
value-text | string | — | Words for the value ("12.4 GB of 15 GB"), shown and announced in place of the percentage or the total. |
Slots
| Name | Description |
|---|---|
(default) | Label shown above the bar; also the meter's accessible name. Falls back to the label attribute. |
value | Replaces the value shown beside the label. Announced text still comes from value-text. |
CSS parts
Shadow DOM styling hooks used with ::part(name). Prefer CSS custom properties when they cover the change.
| Name | Description |
|---|---|
header | Row holding the label and the value. |
label | Container of the label. |
value | Text region containing the custom value slot, or its fallback: value-text, the segments' total or the percentage. |
track | The bar's full range; carries role="meter". |
indicator | The filled part of a single-value meter. |
segment | Each filled part of a segmented meter. |
legend | List of the segments under the bar. |
legend-item | One entry of the legend. |
swatch | Colour mark of a legend entry. |
CSS custom properties
Grouped by semantic target and state from --c2-<component>__<target>__<state>--<property>. Click a group to collapse it; click a name to copy it.
| Name | Type | Default | Description |
|---|---|---|---|
--c2-meter--width | pixel | 100% | Width of the meter; the host is a block. |
--c2-meter--gap | pixel | 8px | Space between the header, the bar and the legend. |
--c2-meter--transition-duration | time | 300ms | How long the bar takes to follow a new value. |
--c2-meter__track--height | pixel | 8px | |
--c2-meter__track--border-radius | border-radius | 999px | Rounds the track and the ends of the fill. |
--c2-meter__track--background-color | color | #e4e4e7 | Colour of the unused range. |
--c2-meter__indicator--background-color | color | #0265dc | Fill while the value is optimum (and always without thresholds). |
--c2-meter__indicator__suboptimum--background-color | color | #d97706 | Fill while the value is sub-optimum. |
--c2-meter__indicator__critical--background-color | color | #dc2626 | Fill while the value is critical. |
--c2-meter__segment--gap | pixel | 2px | Space between two segments. |
--c2-meter__segment-1--background-color | color | #0265dc | Fill of the 1st, 9th, 17th… segment without a color. The eight follow the theme's chart series. |
--c2-meter__segment-2--background-color | color | #ea580c | |
--c2-meter__segment-3--background-color | color | #0f766e | |
--c2-meter__segment-4--background-color | color | #db2777 | |
--c2-meter__segment-5--background-color | color | #a16207 | |
--c2-meter__segment-6--background-color | color | #7c3aed | |
--c2-meter__segment-7--background-color | color | #0891b2 | |
--c2-meter__segment-8--background-color | color | #52525b | |
--c2-meter__label--color | color | #18181b | |
--c2-meter__label--font-size | font-size | 14px | |
--c2-meter__label--font-weight | font-weight | 500 | |
--c2-meter__value--color | color | #71717a | |
--c2-meter__value--font-size | font-size | 14px | |
--c2-meter__value--font-weight | font-weight | 400 | |
--c2-meter__value--display | display | inline | none hides the shown value; it is still announced. |
--c2-meter__legend--display | display | flex | none hides the legend of a segmented meter. |
--c2-meter__legend--row-gap | pixel | 4px | Space between two rows of legend entries. |
--c2-meter__legend--column-gap | pixel | 16px | Space between two legend entries on a row. |
--c2-meter__legend--color | color | #71717a | Colour of a legend entry's label. |
--c2-meter__legend--font-size | font-size | 12px | |
--c2-meter__legend-value--color | color | #18181b | Colour of a legend entry's value. |
--c2-meter__swatch--size | pixel | 8px | |
--c2-meter__swatch--border-radius | border-radius | 999px | |
Text and languages
The text the component shows, in English. It shows another language when the app adds one with addTranslations, under meter, and the nearest lang asks for it; any message not translated stays in English. {0}, {1}… stand for the values a message carries. Languages guide.
| Key | English | Values |
|---|---|---|
label | Meter | — |
total | {0} of {1} | {0} value {1} max |
segment | {0}: {1} | {0} label {1} value |