Meter
Shows a quantity within a known range, such as storage used or a plan’s quota, and turns orange or red near the limit.
Usage
import { Meter, MeterLabel, MeterTrack, MeterValue } from 'nyctoui/meter'
<Meter value={18.4} max={50}>
<MeterLabel>Storage</MeterLabel>
<MeterValue />
<MeterTrack />
</Meter>Meter looks like Progress but means something else: it reports a level, not a task moving toward done. Screen readers announce it as a meter. For uploads, imports and playback, use Progress.
Good for
- Storage used on an account page in a cloud drive.
- Seats used on a team plan, on the billing page.
- API requests used against a monthly quota in a developer console.
- A password strength reading under a new password field.
Examples
Custom value
MeterValue shows a percentage unless the root has a format. Pass a function to write it your own way, and getValueLabel so screen readers hear the same thing.
Tones
The demo at the top of the page. tone colors the indicator 'warning' or 'danger'. It is status only, so the meter doesn’t pick it; decide the thresholds where you know what the limit means, as this example does at 80% and 95%.
Best practices
- Use a meter for a level within a known range, and Progress for a task moving toward done.
- Show the value in words beside the bar, like “7.2 of 10 GB”, with
formatorgetValueLabel. - Let the tone turn orange or red near the limit, and say what to do next, such as a link to upgrade.
- Use a meter for an upload or an import. That’s progress.
- Rely on the color alone to say the limit is close. Put it in the text.
API reference
Meter
Wraps ui-sdk’s Meter and takes its props, including format, locale and getValueLabel.
| Prop | Type | Default |
|---|---|---|
valueCurrent value, clamped to min and max. | number | — |
minValue at an empty bar. | number | 0 |
maxValue at a full bar. | number | 100 |
toneIndicator color, for a level close to or over its limit. | 'neutral' | 'warning' | 'danger' | 'neutral' |
formatHow the value is written in MeterValue and for screen readers. | Intl.NumberFormatOptions | — |
getValueLabelWhat a screen reader announces for the value. | (value: number, details: { formatted, percent, min, max }) => string | — |
sxStyleX styles merged after the built-in ones. | StyleXStyles | — |
MeterLabel
A <span> in the first row that labels the meter.
| Prop | Type | Default |
|---|---|---|
sxStyleX styles merged after the built-in ones. | StyleXStyles | — |
MeterValue
A <span> at the end of the first row showing the formatted value.
| Prop | Type | Default |
|---|---|---|
childrenWrite the value yourself instead of the default. | (state: { value, text, … }) => ReactNode | — |
sxStyleX styles merged after the built-in ones. | StyleXStyles | — |
MeterTrack
The full-width track, with the indicator inside.
| Prop | Type | Default |
|---|---|---|
sxStyleX styles merged after the built-in ones. | StyleXStyles | — |