Meter
Displays a scalar measurement within a known range.
Contract
This Tinyrack wrapper preserves Base UI behavior, React 19 refs, native props, events, and the render contract. Values are clamped to min and max before formatting so the visible value, fill, and ARIA value stay synchronized. Playground controls cover bounded ranges, locale-aware number formatting, and every explicit semantic variant; Reset restores the documented defaults.
Install
pnpm add @tinyrack/uiScroll inside the code area to read long lines.
Styles
@import '@tinyrack/ui/components/meter.css';Scroll inside the code area to read long lines.
Imports
import { TRMeter } from '@tinyrack/ui/components/meter';Scroll inside the code area to read long lines.
Playground
Usage
Examples
Semantic variants permalink
Variant communicates application meaning; it does not infer thresholds from the numeric value.
Custom range and formatted value permalink
A non-zero minimum, unit formatter, and human value text remain bound to the same meter contract.
API
TRMeter.Rootrequiresvalue, defaults tomin={0},max={100}, andvariant="neutral", and forwards native div props,render, and React 19ref. Out-of-range andNaNvalues are clamped before formatting.TRMeter.Labelsupplies the accessible name. When no visible label is appropriate, providearia-labelon Root.TRMeter.Valuedisplays the locale-aware value. Its render function receives the formatted and numeric values.TRMeter.TrackcontainsTRMeter.Indicator; Indicator width represents the normalized position betweenminandmax.- Use
formatandlocalefor visible units, andgetAriaValueTextwhen the numeric value needs context for assistive technology. The semantic variants are explicit; Tinyrack does not infer low/high thresholds.
| CSS token | Default | Purpose |
|---|---|---|
--tr-meter-min-width | --tinyrack-measure-lg | Minimum meter width, capped by its container |
--tr-meter-track-size | --tinyrack-space-sm | Track and indicator thickness |
--tr-meter-track-background | --tinyrack-control-track | Track color |
--tr-meter-indicator-background | Semantic variant color | Indicator color override |