Feedback

Meter

Show a value within a known range.

Rust
1use herogpui::components::meter::Meter;

Usage

Labels and values use 14px text with a 20px line height, independent of the surrounding text style.

Rust
1use herogpui::prelude::Meter;
2use gpui::prelude::*;
3use gpui::px;
4
5gpui::div()
6    .w(px(256.))
7    .child(
8        Meter::new("meter-usage", value)
9            .label("Disk usage")
10            .show_value(true),
11    )

Live HeroGPUI compiled to WebAssembly. Select any example without loading another WASM instance.

Anatomy

Rust types

Meter

Meter is assembled from these builders. The API reference lists each one.

Customization

Appearance builders and theme tokens Meter uses.

Styling

Meter styling
StyleDescription
ProgressBar root layoutFull-width label/output row above the track; 14px text uses a 20px line height.
ProgressBar::size(Size)Track thickness follows the three documented sizes.
ProgressBar::color(Color)Fill color follows the selected semantic role.

API reference

Builders

Meter builders
BuilderTypeDefaultDescription
new(id, value) / value(f32)id, value / f320Current value within the configured range.
min_value(f32)f320Minimum value used to normalize the fill.
max_value(f32)f32100Maximum value used to normalize the fill.
size(Size)SizeSize::MdSelects the meter track thickness.
color(Color)ColorColor::AccentSemantic color of the fill bar.
format_options(NumberFormat)NumberFormat{style: 'percent'}Formats the value label; covers common numeric styles without caller-selected locale data.
value_label(text) / value_content(render)text / AnyElementReplaces the generated value text; accepts text or a value render closure.
label(text) + value_content(render)text) + value_content(renderComposes a label and output renderer while track and fill remain built in.
value_content(render)numberNormalized percentage handed to the output renderer.

Parts

Meter parts
PartDescription
MeterRoot meter state and layout owner.
MeterFormatted output beside the label, customizable through the value closure.
MeterClipped default-color track delegated to ProgressBar.
MeterSemantic fill proportional to the normalized value.

States

Meter states
BuilderStateDescription
ProgressBar::value + min_value + max_valueDeterminateFill width and output follow the normalized value.