Meter
A gauge for a measurement inside a known range: disk used, build minutes left, a password's strength, a score out of a hundred. It styles the native <meter> element, and the browser decides from low, high and optimum whether the value is good, fair or poor — the bar takes the success, warning or danger colour from that judgement, with no script and no class to switch.
Couldn't load the demo. Open alone — Good, fair and poor readings
<div class="iv-stack iv-u-gap-5" style="max-width: 28rem">
<div class="iv-meter-field">
<label for="me-disk">Disk used</label>
<span class="iv-meter-field__value">42 of 100 GB</span>
<meter class="iv-meter" id="me-disk" min="0" max="100" low="70" high="90" optimum="20" value="42">42 GB</meter>
</div>
<div class="iv-meter-field">
<label for="me-quota">Build minutes this month</label>
<span class="iv-meter-field__value">780 of 1,000</span>
<meter class="iv-meter" id="me-quota" min="0" max="1000" low="700" high="900" optimum="100" value="780">780 minutes</meter>
</div>
<div class="iv-meter-field">
<label for="me-mem">Memory</label>
<span class="iv-meter-field__value">95 %</span>
<meter class="iv-meter iv-meter--lg" id="me-mem" min="0" max="100" low="70" high="90" optimum="20" value="95">95 %</meter>
</div>
<p class="iv-u-m-0 iv-u-text-sm iv-u-text-muted">Sample readings. The colour comes from the browser's own judgement of <code>low</code>, <code>high</code> and <code>optimum</code>; the value is always written next to the bar.</p>
</div>Meter or progress?
They look alike and mean different things. A progress bar measures how much of a task is done and moves towards the end; a meter measures a quantity that can go up or down and has a good and a bad end. Uploading a file is progress; the disk the file fills is a meter. Screen readers announce them differently, so the choice is not only visual.
How the colour is chosen
<div class="iv-meter-field">
<label for="disk">Disk used</label>
<span class="iv-meter-field__value">42 of 100 GB</span>
<meter class="iv-meter" id="disk" min="0" max="100"
low="70" high="90" optimum="20" value="42">42 GB</meter>
</div>low and high cut the range into three bands; optimum says which band is the good one. With optimum="20" low values are good, so 42 is green, 780 of 1,000 build minutes is amber and 95 % memory is red. Flip the optimum to the top of the range for a score where high is good. Each engine exposes its own pseudo-elements for the bar; the stylesheet writes one rule per engine, because an unknown pseudo-element would invalidate a whole selector list.
iv-meter-field lays out the label and the written value on one line above the bar. iv-meter--lg is a thicker bar for a dashboard tile.
Accessibility
- Name every meter: a visible
<label for>, as in the field, oraria-label. - Write the value as text next to the bar. Colour is never the reading, and the text content inside
<meter>is only a fallback for very old engines. - The browser exposes the value, the minimum and the maximum to assistive technology; you do not need ARIA value attributes.
- In forced colours the bar becomes a highlight fill on a framed canvas track.
Customising
.quota .iv-meter {
--iv-meter-size: 0.75rem;
--iv-meter-track: var(--iv-color-surface-raised);
}Public locals: --iv-meter-size (the thickness, 0.625rem by default) and --iv-meter-track (the empty part). The three fill colours are the theme's success, warning and danger, so a theme that changes those changes the meter.
Common mistakes
- Using a meter for an upload or a multi-step form: that is progress.
- Omitting
optimum, so the browser guesses which end is good. - A bar with no number beside it.
- Setting the colour with a class. The browser already knows which band the value is in.
Class index
Every class of the family. The full list per stylesheet lives in the reference.
| Class | What it does |
|---|---|
iv-meter | The styled native <meter>. |
iv-meter--lg | Thicker bar. |
iv-meter-field | Label, written value and bar laid out together. |
iv-meter-field__value | The value as text, aligned to the end. |