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

Storage
x

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.

sm
x
md
x
lg
x
ValueDescription
sm4px, for dense lists and rows.
mdThe default 6px track.
lg10px, for a reading in the spotlight.

Variants

Use variant to set the indicator color for a meter without thresholds.

Default
x
Neutral
x
ValueDescription
defaultThe primary color.
neutralNo 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>.

Disk usage
x
Battery
x
Humidity
x

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.

ReadingWhere optimum goes
Lower is betterBelow low, like disk usage.
Higher is betterAbove high, like battery.
Middle is bestBetween 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.

Before breakfast

Target 4.0 to 7.0 mmol/L

x
Before lunch

Target 4.0 to 7.0 mmol/L

x

Live Readings

Update value as often as you like; the indicator eases to each reading and fades its color across thresholds.

CPU load
x

Segments

Set segments on MeterTrack to split the track into equal blocks, which replace the threshold notches.

Password strength
x
Trackpad battery
x

Custom Range and Format

Use min, max, and format to measure in your own units.

Monthly cloud spend
x
Average rating
x

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

AttributeElementDescription
data-statusRootoptimum, suboptimum, or critical when thresholds apply.
data-sizeRootThe current size.
data-segmentedTrackPresent when segments is greater than 1.
data-target-rangeRootPresent when low and high are both set and optimum sits between them.

CSS Variables

VariableElementDescription
--meter-colorRootIndicator color, set by variant or data-status.
--meter-segment-gapTrackGap between segments. Defaults to 3px.
--meter-target-startRootWhere the target range starts, as a percentage of the track.
--meter-target-sizeRootWidth of the target range, as a percentage of the track.