Meter

Meters display a scalar value within a known range, using color to signal whether it's optimal, suboptimal, or least optimal.

Storage used

Overview

Meters are components that display scalar values within a known range. They display values in a visual way that makes it easy to compare and contrast values, or see how much a value compares to a whole.

Usage

forge-meter shows a scalar value within a min/max range through value, tickmarks, and an optional low/high/optimum split that colors the track green, yellow, or red depending on where value falls. Reach for a meter when the value is a relatively static data point, like a storage quota or a satisfaction score — for a task’s busy or in-progress state, use linear progress instead; despite the visual similarity, the two represent fundamentally different things.

Rules

Do
Always give a meter an accessible label, either via a label element association or aria-label/aria-labelledby.Set optimum so the meter's color reflects whether the current value is actually good, not just its raw position in the range.Pair a grouped meter with a key labeling each meter's color and value.
Don't
Don't use a meter to represent a task's busy or loading state — use linear progress instead.Don't segment a meter (low/high) and group it at the same time — grouped meters can't be segmented.Don't rely on color alone to convey a segmented meter's optimal/suboptimal/least-optimal state.

Segmented

Set low and high to divide the track into three regions — below low, between low and high, and above high — colored green, yellow, or red depending on which region optimum falls in relative to value. low must be greater than or equal to min and less than high; high must be less than or equal to max and greater than low.

A segmented meter, colored by how close its value is to the optimum region.

Tickmarks

Set tickmarks to show evenly spaced marks along the track; control how many with the --forge-meter-tickmarks token.

A meter with tickmarks along its track.

Grouped

Wrap same-range meters in forge-meter-group to lay them out together on a single shared track — useful for parts of a whole. Grouped meters can’t be segmented, and every meter in the group must share the same min/max. Pair a grouped meter with a key labeling each meter’s color and, optionally, its value.

Several related meters grouped on one shared track.

Meters display a scalar value within a defined range.

import "@tylertech/forge/meter";
Properties
PropertyAttributeTypeDefaultDescription
valuevaluenumber0The current value of the meter.
minminnumber0The minimum value of the meter.
maxmaxnumber1The maximum value of the meter.
lowlownumber | null | undefined0The low value threshold.
highhighnumber | null | undefined1The high value threshold.
optimumoptimumnumber | null | undefined1Indicates the region of the optimum value.
tickmarkstickmarksbooleanfalseWhether to display tickmarks.
valueModevalue-modeMeterValueMode'manual'Whether the current value is displayed as a percentage or raw value. When set to `'manual'` the value text is not shown automatically but can still be set manually via the value slot.
directiondirectionMeterDirection'horizontal'Whether the meter is oriented horizontally or vertically.
shapeshapeMeterShape'default'The shape of the meter.
innerShapeinner-shapeMeterInnerShape'default'The shape of the bar.
densitydensityMeterDensity'medium'The density of the meter.
themethemeMeterTheme'default'The theme of the meter.
mutedmutedbooleanfalseWhether the theme is muted.
percentage—number—Gets the percentage of the meter that's filled.
—aria-valuetextstring—Defines a text alternative for the current value. Set this if it would be inaccurate to read the value as a percentage.
Slots
NameDescription
(default)The default slot for the meter's label.
valueA textual representation of the meter's value.
CSS Parts
NameDescription
::part(root)The root container element.
::part(track)The element comprising the meter's background.
::part(bar)The bar representing the value.
CSS Custom Properties
NameDescription
--forge-meter-backgroundThe background color of the meter.
--forge-meter-colorThe color of the meter's bar.
--forge-meter-heightThe block size of the meter.
--forge-meter-shapeThe border radius of the meter.
--forge-meter-bar-inner-shapeThe border radius of the meter's bar.
--forge-meter-tickmarksThe number of tickmarks to display.
--forge-meter-tickmark-opacityThe opacity of the tickmarks.
--forge-meter-transition-durationThe duration of transitions.
--forge-meter-transition-timingThe timing function of transitions.
--forge-theme-successThe color of the bar when the value is optimal.
--forge-theme-success-container-lowThe color of the track when the value is optimal.
--forge-theme-warningThe color of the bar when the value is suboptimal.
--forge-theme-warning-container-lowThe color of the track when the value is suboptimal.
--forge-theme-errorThe color of the bar when the value is least optimal.
--forge-theme-error-container-lowThe color of the track when the value is least optimal.

Labeling

Always give a meter an accessible label — associate it with a <label> element, or set aria-label/aria-labelledby directly. Text placed in the meter’s label slot isn’t accessible on its own; it still needs to be linked to the meter one of those ways. For a grouped meter, also provide a key naming each meter’s color and, optionally, its value.

Automatic ARIA

The meter automatically applies ARIA attributes reflecting its value, min, and max. If the value isn’t naturally a percentage — a discrete count, or a textual quantifier like “low”/“medium”/“high” — set aria-valuetext to a string describing how it should be read instead.

Type to search the docs.

NavigateSelectClose
Loading Forge chat…