Meter
A bar that shows a measured value within a known range.
Usage guidelines
- Use Meter for a measurement, not a task: A meter shows where a value sits in a known range, such as quota usage, storage or a score, and that value can rise or fall at any time. A value that only moves toward done, such as an upload or an indexing run, uses
Progress. Both draw the same bar, but assistive technology announces them asmeterandprogressbar, so choose by meaning, not by look. - Name the meter: Use
MeterLabelfor a visible label; it names the root. Without one, giveMeteranaria-label. - Set the real range: Pass
minandmaxin the unit being measured instead of converting to a percentage. The value text defaults to a percentage of the range; passformatto show the number itself, andgetAriaValueTextwhen the number alone does not say what is counted. - Choose the tone from the value:
MeterIndicatortakestone="warning"ortone="error". The caller decides the thresholds, and the visible text still states the value.
Anatomy
Meter renders no layout of its own, so the caller places the label and value around the track.
Examples
Tones
neutral (the default), warning and error color the indicator. This example switches at 80% and at the limit.
Formatted value
format takes Intl.NumberFormat options for both MeterValue and aria-valuetext. Without it, MeterValue displays a percentage of the range (84% here); passing style: 'unit' formats the measured value directly, and locale keeps the unit and decimal separator consistent across browsers.
API reference
Meter
Displays a numeric value within a known range, such as quota usage, capacity, or a score. Renders a <div> element.
Use Progress instead for task completion; role="meter" and role="progressbar" are not interchangeable.
| Prop | Type | Default | Details |
|---|---|---|---|
aria-valuetext | string | No default | |
format | Intl.NumberFormatOptions | No default | |
getAriaValueText | ((formattedValue: string, value: number) => string) | No default | |
locale | Intl.LocalesArgument | No default | |
max | number | 100 | |
min | number | 0 | |
value required | number | No default | |
className | string | ((state: MeterRootState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, MeterRootState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: MeterRootState) => React.CSSProperties | undefined) | No default | |
MeterIndicator
Visualizes the position of the value along the range. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
tone | 'error' | 'neutral' | 'warning' | 'neutral' | |
className | string | ((state: MeterIndicatorState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, MeterIndicatorState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: MeterIndicatorState) => React.CSSProperties | undefined) | No default | |
MeterLabel
An accessible label for the meter. Renders a <span> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: MeterLabelState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, MeterLabelState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: MeterLabelState) => React.CSSProperties | undefined) | No default | |
MeterTrack
Contains the meter indicator and represents the entire range of the meter. Renders a <div> element.
| Prop | Type | Default | Details |
|---|---|---|---|
className | string | ((state: MeterTrackState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, MeterTrackState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: MeterTrackState) => React.CSSProperties | undefined) | No default | |
MeterValue
A text element displaying the current value. Renders a <span> element.
| Prop | Type | Default | Details |
|---|---|---|---|
children | ((formattedValue: string, value: number) => React.ReactNode) | null | No default | |
className | string | ((state: MeterValueState) => string | undefined) | No default | |
render | ComponentRenderFn<HTMLProps, MeterValueState> | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | No default | |
style | React.CSSProperties | ((state: MeterValueState) => React.CSSProperties | undefined) | No default | |