Meter
Indicators
Open in Storybook: Meter (opens in a new tab)
Overview
A meter shows a measurement inside a known range: fuel level, storage used, battery, a 0–10 intensity, a rating shown on a product card. It is read-only and never takes focus. The component is the native meter: the browser already maps min, max and value to the accessibility tree. A custom look (squares, stars) is painted on top of it and hidden from assistive technology.
The rule. The meter element holds the information; everything else is decoration. Never rebuild the meter out of divs and ARIA.
Anatomy
- Label
label forNames the meter. Always visible.
- Track
meter,::-webkit-meter-barThe range from min to max. The meter holds the role, the name, the value and the range.
- Fill
::-webkit-meter-optimum-valueand its two siblingsPainted by the browser from low, high and optimum: purple is the good zone, yellow the middle, red the worst.
- Status
p aria-hidden="true"with ansvgWhere the value is, in a word and a shape (check, dash, warning), so colour is never the only cue.
- Value text
span aria-hidden="true"The visible copy of the value. Hidden because the meter already exposes it.
- Marks
div aria-hidden="true"A custom design: squares or stars, one for each unit. The native meter sits invisible over them.
Usage
Use cases
Eight common meters, each the real component and each working: move the slider under one to try a value. Purple is the best zone, yellow the middle, red the worst. The value text, not the colour, carries the status.
Fuel level
Higher is better.
80 out of 100, good Says “80 out of 100, good”.
min=0 max=100 low=33 high=66 optimum=80 value=80Storage used
Lower is better.
12.4 of 16 GB used, filling up Says “12.4 of 16 GB used, filling up”.
min=0 max=16 low=8 high=13 optimum=4 value=12.4Battery
Higher is better, warn when low.
15%, low Says “15%, low”.
min=0 max=100 low=20 high=80 optimum=100 value=15Password strength
0 to 4, higher is better.
Weak Says “Weak”.
min=0 max=4 low=2 high=3 optimum=4 value=1Coffee intensity
Custom squares, no zones.
7 out of 10 Says “7 out of 10”.
min=0 max=10 value=7Product rating
Static info only.
4 out of 5 stars Says “4 out of 5 stars”.
min=0 max=5 value=4Accessibility score
Higher is better.
92 out of 100, good Says “92 out of 100, good”.
min=0 max=100 low=50 high=90 optimum=100 value=92Room humidity
Middle is best.
45%, comfortable Says “45%, comfortable”.
min=0 max=100 low=30 high=60 optimum=45 value=45
Props
| Prop | Does | Default |
|---|---|---|
label | Names the meter. Always visible | Required |
value | The measurement | Required |
max | Top of the range | Required |
min | Bottom of the range | 0 |
low · high · optimum | Passed to the meter as they are. They cut the range into three zones | The browser’s: min, max, the midpoint |
words | What each region is called: { low, middle, high }. With them the field shows the status as a word and a shape, and the word goes into aria-valuetext | None: no status |
valueText | The value in words, (value, max) => string. Empty when the status word is the whole text (“Weak”) | “80 out of 100” |
shown | The visible copy of the value, (value, max) => string, or null for none | “80 / 100” |
look | bar, squares or stars. The squares and stars are one for each unit, over an invisible native meter | bar |
Example
words turns the zone into a word and a shape: this meter says “20 out of 100, low”. look swaps the bar for squares or stars.
import { Meter } from '@/components/Meter'
<Meter
label="Fuel level"
value={20}
max={100}
low={33}
high={66}
optimum={80}
words={{ low: 'Low', middle: 'Medium', high: 'Good' }}
/>
<Meter label="Intensity" value={7} max={10} look="squares" />Specs
Measurements
| Part | Property | Value |
|---|---|---|
| Field | Gap | 8px · 12px (0.5rem · 0.75rem) |
| Label | Text | 13px (0.8125rem) / 1.45, 700 |
| Bar | Height · corner | 20px (1.25rem) · 6px |
| Bar | Border | 2px solid |
| Fill | Edge | 2px line on its end |
| Segment | Size · gap | 10 × 20px · 3px |
| Star | Size · gap | 20 × 20px, 1.5px line · 4px |
| Status | Text · icon | 13px (0.8125rem) / 1.4, 600 · 16px icon, 6px gap |
| Value text | Text | 12px (0.75rem) / 1.45, monospace, tabular numbers |
| Label · value text | Width from 48rem | 9rem · 11rem at the least |
Attributes
min, max and value place the measurement. low and high cut the range into three zones. optimum says which zone is the good one; the other two are ranked by their distance from it.
| Attribute | Meaning | Default |
|---|---|---|
min | Lowest value of the range | 0 |
max | Highest value of the range. Always set | 1 |
value | The current measurement. Keep it between min and max | 0 |
low | Upper edge of the “low” zone | min |
high | Lower edge of the “high” zone | max |
optimum | The best value | The midpoint |
aria-valuetext | The value in words, with the status | None: the number is read |
Zones
Browsers paint best, middle and worst in green, yellow and red. Here they are purple, yellow and red.
| Optimum is | Value below `low` | Between | Value above `high` |
|---|---|---|---|
Between low and high (middle is best: humidity) | middle | best | middle |
Below low (lower is better: storage) | best | middle | worst |
Above high (higher is better: fuel, battery) | worst | middle | best |
A value on low or high joins the optimum’s region, as the browser paints it: with the optimum below low, a value equal to low is still the best zone. A rule that tests value < low and value > high is wrong on the edges. Chromium 148 paints all 70 combinations tested this way.
Status
| Where the value is | Zone | Fill | Icon | Word | Status words, chosen for each meter |
|---|---|---|---|---|---|
| Same region as the optimum | Best | Purple | Check in a circle | Purple | Good · Plenty of space · Comfortable |
| Next to the optimum region | Middle | Yellow | Dash in a circle | Ink | Medium · Filling up · Too dry · Too humid |
| Far side from the optimum | Worst | Red | Warning triangle | Red | Low · Almost full |
Layout
A meter is not interactive, so zoom is about reflow: the label, the bar and the value text stay readable and stay together at every width. The breakpoints are container queries in rem, so they follow the room the field has and the size of the text: a field in a narrow card stacks on a wide screen. One DOM at every width, only the CSS changes, so the reading order never changes. In Storybook, pick the width in the viewport menu of the toolbar: 640 CSS px · 200% zoom or 320 CSS px · 400% zoom.
| Breakpoint | CSS width | Reached by | Layout |
|---|---|---|---|
| ≥ 48rem | ≥ 768px | Desktop at 100–150% zoom | One row: label · bar · value text |
| 30–48rem | 480–767px | 1280px at 200% zoom (640 CSS px) · tablets · text at 200% | Label and value text on one row, bar full width below |
| < 30rem | < 480px | 1280px at 400% zoom (320 CSS px) · phones | Stacked: label, bar, value text. No sideways scroll |
Markup
<label for="fuel">Fuel level</label>
<meter id="fuel" min="0" max="100" low="33" high="66" optimum="80" value="20"
aria-valuetext="20 out of 100, low">20 out of 100, low</meter>
<p aria-hidden="true"><svg focusable="false">…</svg> Low · 20 / 100</p>Styling
One rule for each engine: a selector list that mixes ::-webkit-meter-* and ::-moz-meter-* is dropped whole by the engine that does not know one.
| Part | WebKit · Blink | Firefox |
|---|---|---|
| Wrapper | ::-webkit-meter-inner-element | — |
| Track | ::-webkit-meter-bar | The element itself |
| Fill, good zone | ::-webkit-meter-optimum-value | :-moz-meter-optimum::-moz-meter-bar |
| Fill, middle zone | ::-webkit-meter-suboptimum-value | :-moz-meter-sub-optimum::-moz-meter-bar |
| Fill, worst zone | ::-webkit-meter-even-less-good-value | :-moz-meter-sub-sub-optimum::-moz-meter-bar |
meter { appearance: none; inline-size: 100%; block-size: 1.25rem; }
meter::-webkit-meter-inner-element { appearance: none; block-size: 100%; }
meter::-webkit-meter-bar {
block-size: 100%;
background: #e6e6ea;
border: 2px solid #16161a;
border-radius: 6px;
}
meter::-webkit-meter-optimum-value,
meter::-webkit-meter-suboptimum-value,
meter::-webkit-meter-even-less-good-value {
border-inline-end: 2px solid #16161a; /* where the fill stops */
}
meter::-webkit-meter-optimum-value { background: #5e548e; }
meter::-webkit-meter-suboptimum-value { background: #ffe600; }
meter::-webkit-meter-even-less-good-value { background: #82002a; }
meter:-moz-meter-optimum::-moz-meter-bar { background: #5e548e; }
meter:-moz-meter-sub-optimum::-moz-meter-bar { background: #ffe600; }
meter:-moz-meter-sub-sub-optimum::-moz-meter-bar { background: #82002a; }Tokens
Component tokens
| Part | Property | Token | Value |
|---|---|---|---|
| Bar | Border width | bw | 2px |
| Bar | Border and fill edge colour | ink | #16161a |
| Bar | Corner | — | 6px |
| Track | Fill | — | #e6e6ea |
| Fill, best | Fill | lilac | #5e548e |
| Fill, middle | Fill | marker | #ffe600 |
| Fill, worst | Fill | danger | #82002a |
| Segment, on | Fill | — | #5d5fef |
| Segment, off | Border · fill | — · white | #6b6b75 · #ffffff |
| Star | Filled · outline | — | #5d5fef · #6b6b75 |
| Label | Text colour | ink | #16161a |
| Value text | Text colour | ink-soft | #4b4b55 |
| Status, best | Text and icon | lilac | #5e548e |
| Status, middle | Text · icon | ink · marker | #16161a · #ffe600 |
| Status, worst | Text and icon | danger | #82002a |
Guidelines
Meter or something else
| Element | Use it for | The user changes it | Role | Examples |
|---|---|---|---|---|
meter | A measurement inside a known range | No | meter | Fuel 80 / 100 · 12.4 of 16 GB used · 3.5 out of 5 stars on a product card · a password-strength or audit score · humidity in a comfort range |
progress | Completion of a task | No | progressbar | Upload at 40% · step 2 of 5 of an install · indeterminate loading |
input type="range" | Picking a value on a continuous scale | Yes, keyboard and pointer | slider | Volume · brightness · price filter |
| Radio group | Picking one of a few discrete options | Yes, arrow keys | radiogroup, radio | “Rate this coffee” 1–5 stars · cup size S / M / L |
| Plain text | A number with no known range | No | — | 1,204 followers |
If the user can change the value, it is a form control, even when the design makes it look like a meter.
Controls by scenario and context
Each row is a use case, drawn with the real component at half size. The status word moves under the bar for room; it is never dropped.
- Solid: required in that context, never dropped
Zoom 400% · 320 CSS px. At 200% text size the layout drops to the middle column by itself.
Fuel level
Higher is better
- Desktop · 768 px and up48rem · one row
Label · bar · value text · status word
low 33 · high 66 · optimum 80. aria-valuetext “80 out of 100, good”.
- Smaller viewport · 480–767 px30–48rem
Label · bar · status word below
Bar fills the column; the status word moves under it.
- Zoom 400% · 320 CSS pxUnder 30rem · stacked
Label · bar · status word
Label and value text wrap above the bar. Status never by colour alone.
Storage used
Lower is better
- Desktop · 768 px and up48rem · one row
Label · bar · value text · status word
low 8 · high 13 · optimum 4. “12.4 of 16 GB used, filling up”.
- Smaller viewport · 480–767 px30–48rem
Label · bar · status word below
Same zones; value text on its own line.
- Zoom 400% · 320 CSS pxUnder 30rem · stacked
Label · bar · status word
“12.4 of 16 GB” wraps; nothing truncated.
Battery
Higher is better, warn when low
- Desktop · 768 px and up48rem · one row
Label · bar · value text · status word
low 20 · high 80 · optimum 100. “15%, low”: low is a word, not only red.
- Smaller viewport · 480–767 px30–48rem
Label · bar · status word below
Same.
- Zoom 400% · 320 CSS pxUnder 30rem · stacked
Label · bar · status word
Same. The warning stays text.
Password strength
0 to 4, updates while typing
- Desktop · 768 px and up48rem · one row
Label · bar · status word
low 2 · high 3 · optimum 4. “Weak”.
- Smaller viewport · 480–767 px30–48rem
Label · bar · status word below
Sits under the password field, inside its description.
- Zoom 400% · 320 CSS pxUnder 30rem · stacked
Label · bar · status word
Same; the word is what counts at this size.
Coffee intensity
Custom squares, no zones
- Desktop · 768 px and up48rem · one row
Label · squares (aria-hidden) · native meter at opacity 0
min 0 · max 10 · value 7. “7 out of 10”. No status: no zones.
- Smaller viewport · 480–767 px30–48rem
Label · squares
Squares shrink before they overflow.
- Zoom 400% · 320 CSS pxUnder 30rem · stacked
Label · squares · value text
Value text “7 / 10” always visible next to the squares.
Accessibility score
Higher is better
- Desktop · 768 px and up48rem · one row
Label · bar · value text · status word
low 50 · high 90 · optimum 100. “92 out of 100, good”.
- Smaller viewport · 480–767 px30–48rem
Label · bar · status word below
Same.
- Zoom 400% · 320 CSS pxUnder 30rem · stacked
Label · bar · status word
Same.
Room humidity
Middle is best
- Desktop · 768 px and up48rem · one row
Label · bar · value text · status word
low 30 · high 60 · optimum 45. “45%, comfortable”.
- Smaller viewport · 480–767 px30–48rem
Label · bar · status word below
Same.
- Zoom 400% · 320 CSS pxUnder 30rem · stacked
Label · bar · status word
Same.
Say where the value is
The browser uses low, high and optimum to paint a colour, and nothing else. The zone is never exposed to assistive technology, and a colour alone tells sighted users nothing if they can’t tell red from yellow. So the status is worked out in code from the same attributes and said in words, twice.
| Cue | Where | What it says |
|---|---|---|
| Words and icon | Next to the label, aria-hidden because the next cue carries it | “Low”, “Filling up”, “Too humid”, with a shape for each zone: check, dash, warning. It survives without colour |
aria-valuetext | On the meter | “20 out of 100, low”. The name, the value and where it sits, in one stop |
| Colour | The fill | A quick extra for those who see it. Never the only cue, and words never refer to it (“in the red”) |
Humidity shows why words are required: “Too dry” and “Too humid” are the same zone and the same colour, on opposite sides of the range. Key the words by region (below low, between, above high), not by colour. The yellow fill is 1.02:1 against the track, so the 2px ink edge on the end of the fill shows where it stops.
Custom designs
When the default bar is not enough, the design is hidden from assistive technology and the information stays on the native meter.
| Layer | Rule |
|---|---|
| The meter | One native meter with min, max, value, a name and aria-valuetext |
| The design | aria-hidden="true" on the squares, the star icons and the numbers inside them. focusable="false" on an svg |
| The overlay | position: absolute; inset: 0; opacity: 0; pointer-events: none on the meter. Never display: none or visibility: hidden |
<div class="meter">
<label for="intensity">Intensity</label>
<div class="meter-scale">
<div class="meter-marks" aria-hidden="true">
<span class="meter-mark" data-on="true"></span> <!-- × 7 -->
<span class="meter-mark"></span> <!-- × 3 -->
</div>
<meter id="intensity" min="0" max="10" value="7"
aria-valuetext="7 out of 10">7 out of 10</meter>
</div>
<p class="meter-value" aria-hidden="true">7 / 10</p>
</div>.meter-scale { position: relative; }
.meter-scale > meter {
position: absolute;
inset: 0;
inline-size: 100%;
block-size: 100%;
opacity: 0; /* not display: none, not visibility: hidden */
pointer-events: none;
}A visually hidden meter (.sr-only) also works, but the screen reader cursor then sits on a 1px box away from the design.
Content
| Part | Format | Example |
|---|---|---|
| Label | What is measured | “Fuel level” · “Storage” |
| Value text | The value, then what it is of, in words | “80 out of 100” · “12.4 of 16 GB used” · “7 out of 10” |
| Status word | One for each side of the range, by what it means and not by colour | “Low · Medium · Good” · “Too dry · Comfortable · Too humid” |
| Visible value | Short, in the same unit | “80 / 100” · “12.4 / 16 GB” · “15%” |
Text inside meter | The fallback for browsers without it: the value text, short | “80 out of 100, good” |
Behavior
| Event | Result |
|---|---|
| Any change of the value | value, aria-valuetext, the text inside the meter and the status change together |
| A value outside the range | The browser clamps it. The marks never show more than the range |
No low, high or optimum | The browser’s defaults. A custom design has no zones and no status |
| Marks | One for each unit of the range, the first ones lit. 3.5 lights four; the value text keeps 3.5 |
| Status word with no number | The word is the whole value text: “Weak” |
Anti-patterns
| Wrong | What goes wrong |
|---|---|
div role="meter" with aria-valuenow | Rebuilds in ARIA what meter already does, and the svgs are still exposed. One missing attribute and the value is gone |
progress for a measurement, or meter for task progress | Different roles, different meaning |
A hidden meter and a span that says the value | display: none, visibility: hidden or aria-hidden take the meter out of the tree. The span is plain text: no role, no range, and it drifts from the value |
| Squares or stars with no meter | A screen reader reads eleven squares one by one. No role, no name, no value, no range |
| Colour as the only cue | Only the red fill says “low”. Screen readers hear “20”, and sighted users who can’t tell the red get nothing |
| Editable stars on a meter | A rating the user can change is a radio group, not a meter |
max left at 1 | value="7" with the default max of 1: the meter reads as full |
Accessibility
Keyboard
| Key | Action | Native |
|---|---|---|
| Tab | Skips the meter: it is not a tab stop. No tabindex | Yes |
| Arrow keys | Nothing: the value is not the user’s to change. No onclick, no role="button" | Yes |
Screen reader
A meter is static: it shows a value, not the progress of that value, and announces nothing. A changed value is read when the user reaches the meter. The exact words differ by screen reader, browser and platform: some say a percentage, some the raw number, and the role may be spoken as meter, level indicator or progress bar. aria-valuetext makes the spoken value explicit.
| Moment | What is read |
|---|---|
| Reach the meter | Its role, its name, aria-valuetext and the range: “Fuel level”, meter, “80 out of 100, good” |
| The value changes | Nothing. The new value is read the next time the meter is reached |
| The page loads | Nothing |
Test, don’t assume: at least VoiceOver with Safari (macOS and iOS) and NVDA with Firefox or Chrome. In each, check that:
- The name is read.
- The value text is read, not the raw number.
- The decoration is silent.
- There is one stop for each meter.
Roles and properties
| Property | Exposed | Rule |
|---|---|---|
| Role | meter | Native. Never role="meter" on a div |
| Name | “Fuel level” | From label for. aria-labelledby when the name is in several elements, aria-label only with no visible text. Without a name it is announced as just a value |
| Value | “80 out of 100, good” | aria-valuetext whenever the bare number is not enough: units, a scale, a status. Without it the number alone is read. Never aria-valuenow |
| Range | min 0 · max 100 | From the native attributes |
| Not in the tree | Status, value text, marks, stars | aria-hidden="true", and focusable="false" on an svg. The visible value text is hidden because the meter already exposes the value: never hide the only copy |
| Always in the tree | The meter | Never display: none, visibility: hidden, hidden or aria-hidden on it. Hide the decoration instead |
Support
Chromium 148 and 149, WebKit 26.4. The Firefox rules follow the design and have not been run.
| Browser | Bar parts | Checked |
|---|---|---|
| Chromium | ::-webkit-meter-* | Yes |
| WebKit (Safari) | ::-webkit-meter-* | Yes |
| Firefox | ::-moz-meter-bar with :-moz-meter-optimum, -sub-optimum, -sub-sub-optimum | No |
WCAG criteria
| Criterion | Requirement here |
|---|---|
| 1.1.1 Non-text Content (A) | The marks, the stars and the icons are decoration, aria-hidden. The meter carries the information |
| 1.3.1 Info and Relationships (A) | label for names the meter. Role, value and range are native |
| 1.4.1 Use of Color (A) | The zone is a word and a shape as well as a colour, and is in aria-valuetext |
| 1.4.3 Contrast (Minimum) (AA) | Label 18:1, value text 8.6:1, status words 6.7:1 (purple) and 10.6:1 (red) |
| 1.4.4 Resize Text (AA) | Label, value text and bar height in rem, so they grow with the user’s font size. No fixed height on the field |
| 1.4.10 Reflow (AA) | 1280px at 400% is 320 CSS px: one column, label, bar, value text. No sideways scroll, no clipped value text |
| 1.4.11 Non-text Contrast (AA) | Bar border and fill edge 18:1, empty marks 5.3:1, filled marks 4.8:1, at every zoom level |
| 1.4.12 Text Spacing (AA) | With line height 1.5, letter spacing 0.12em and word spacing 0.16em, label, status and value text wrap instead of clipping |
| 4.1.2 Name, Role, Value (A) | Native meter, label for, aria-valuetext |
Related
This section is still in progress.
References
This section is still in progress.