Meter
Displays a numeric measurement within a range.
Storage Used
Installation
Install the following dependencies:
Set up the token layer and the StyleX compiler. See
Installation for state-styles.ts. Install
Progress for the shared bar styles.
Copy and paste the following code into your project.
Update the import paths to match your project setup.
Usage
Give the meter a MeterLabel or an aria-label to name the measurement.
Anatomy
Meter renders MeterTrack and MeterIndicator after its children.
API reference
Each part accepts its Base UI Meter props,
including render, plus xstyle, className and real inline style.
Meter
| Prop | Type | Default |
|---|---|---|
value | number | — |
min | number | 0 |
max | number | 100 |
format | Intl.NumberFormatOptions | — |
locale | Intl.LocalesArgument | runtime locale |
getAriaValueText | (formattedValue: string, value: number) => string | — |
Use format and locale to format the value. value must be a number;
use Progress for indeterminate tasks.
MeterValue
| Prop | Type | Default |
|---|---|---|
children | (formattedValue: string, value: number) => ReactNode | — |
meterStyles
| Key | What it is |
|---|---|
root | Wrapping label and value row |
track | Rounded groove |
indicator | Filled bar and reduced-motion-aware width transition |
label | Label type |
value | Muted, tabular number aligned to the end |
Data attributes
| Attribute | On | Effect |
|---|---|---|
data-slot="meter" | root | Targets the measurement |
data-slot="meter-track" | track | Targets the groove |
data-slot="meter-indicator" | indicator | Targets the fill |
data-slot="meter-label" | label | Targets the label |
data-slot="meter-value" | value | Targets the number |