Meter
Show a measurement in a known range, colored by how good the reading is
Primitive
A meter shows a measurement in a known range, like disk usage, battery level, or a score. Give it thresholds and it turns green, amber, or red by how good the reading is. For a task that moves toward completion, use Progress instead.
Preview
Installation
Usage
Composition
The root puts the label and value on the first row and spans everything else below, so you don't need a wrapper.
Examples
Sizes
Use size to set the track thickness.
| Value | Description |
|---|---|
sm | 4px, for dense lists and rows. |
md | The default 6px track. |
lg | 10px, for a reading in the spotlight. |
Variants
Use variant to set the indicator color for a meter without thresholds.
| Value | Description |
|---|---|
default | The primary color. |
neutral | No hue, for quiet readings like storage. |
Once you set thresholds, the status colors take over.
Thresholds
Use low and high to split the range into three regions, and optimum to mark the best one, as on the native <meter>.
A reading in the optimum's region is green, the next region amber, and the far region red. A notch marks each threshold on the track.
| Reading | Where optimum goes |
|---|---|
| Lower is better | Below low, like disk usage. |
| Higher is better | Above high, like battery. |
| Middle is best | Between low and high, like humidity. |
Target Range
Add MeterTargetRange after the track to underline the range from low to high when optimum sits between them. Leaving out optimum counts, since it defaults to the midpoint of min and max.
Target 4.0 to 7.0 mmol/L
Target 4.0 to 7.0 mmol/L
Live Readings
Update value as often as you like; the indicator eases to each reading and fades its color across thresholds.
Segments
Set segments on MeterTrack to split the track into equal blocks, which replace the threshold notches.
Custom Range and Format
Use min, max, and format to measure in your own units.
Accessibility
Screen readers skip MeterValue and read the root's value text, and they can't see the status color. getAriaValueText receives the status as a third argument, so you can announce it:
With reduced motion on, the indicator jumps between values instead of easing.
API Reference
The Meter component is built on top of Base UI's Meter. All Base UI props are supported. The documentation below only covers custom props and modified defaults specific to our implementation.
For the complete Base UI API, see the Base UI Meter documentation.
Props
MeterRoot
Holds the value, works out the status, and lays out the parts. Wraps Base UI's Meter.Root.
MeterTrack
The full range of the meter. Wraps Base UI's Meter.Track.
MeterTargetRange
A line under the track spanning low to high, shown when optimum sits between them, including the default midpoint. A plain <div>, hidden from screen readers, so state the range in text too. Meter always renders it; to leave it out, compose the parts without it.
MeterIndicator
The filled part of the track, colored by status. Wraps Base UI's Meter.Indicator.
Data Attributes
| Attribute | Element | Description |
|---|---|---|
data-status | Root | optimum, suboptimum, or critical when thresholds apply. |
data-size | Root | The current size. |
data-segmented | Track | Present when segments is greater than 1. |
data-target-range | Root | Present when low and high are both set and optimum sits between them. |
CSS Variables
| Variable | Element | Description |
|---|---|---|
--meter-color | Root | Indicator color, set by variant or data-status. |
--meter-segment-gap | Track | Gap between segments. Defaults to 3px. |
--meter-target-start | Root | Where the target range starts, as a percentage of the track. |
--meter-target-size | Root | Width of the target range, as a percentage of the track. |