Skip to content

Meter

Displays a scalar measurement within a known range and semantic low, high, and optimum bands.

Loading interactive demo…

#Import

Import meter from quickgui.

use quickgui::*;

#Usage

meter(70.0, 0.0, 100.0).w(240.0).h(8.0)

#Anatomy

  • meter::root
  • meter::track
  • meter::indicator
  • meter::label
  • meter::value

#API reference

Expand an entry for its description and complete signature. A dash means no declaration default is documented.

pub fn new(value: f64, minimum: f64, maximum: f64) -> Self

Create a meter. Non-finite bounds fall back to `0.0..=1.0` and an inverted range is swapped.

lowpub fn low(mut self, low: f64) -> Self—

Mark the upper end of the low range. Values outside the meter bounds are clamped.

pub fn low(mut self, low: f64) -> Self
View source
highpub fn high(mut self, high: f64) -> Self—

Mark the lower end of the high range.

pub fn high(mut self, high: f64) -> Self
View source
optimumpub fn optimum(mut self, optimum: f64) -> Self—

Mark the most favorable value inside the range.

pub fn optimum(mut self, optimum: f64) -> Self
View source
idpub fn id(mut self, id: impl Into<ElementId>) -> Self—

Give this meter a stable identity so its label and value parts can be related to it.

pub fn id(mut self, id: impl Into<ElementId>) -> Self
View source
formatpub fn format(mut self, format: ValueFormat) -> Self—

Attach a bounded value formatter, Base UI's `format` prop.

pub fn format(mut self, format: ValueFormat) -> Self
View source
value_textpub fn value_text(mut self, text: impl Into<Arc<str>>) -> Self—

Attach a human-readable value that assistive technology prefers over the raw number. This is Base UI's `getAriaValueText`; an empty string clears it. It wins over [`Self::format`].

pub fn value_text(mut self, text: impl Into<Arc<str>>) -> Self
View source
display_valuepub fn display_value(&self) -> Option<Arc<str>>—

The formatted text for a caller-owned value part.

pub fn display_value(&self) -> Option<Arc<str>>
View source
accessible_valuepub fn accessible_value(&self) -> Option<Arc<str>>—

The text assistive technology reads for the value, if any.

pub fn accessible_value(&self) -> Option<Arc<str>>
View source
label_idpub fn label_id(&self) -> Option<ElementId>—

Stable identity of the label part, when this meter declares one.

pub fn label_id(&self) -> Option<ElementId>
View source
value_idpub fn value_id(&self) -> Option<ElementId>—

Stable identity of the value part, when this meter declares one.

pub fn value_id(&self) -> Option<ElementId>
View source
track_idpub fn track_id(&self) -> Option<ElementId>—

Stable identity of the track part, when this meter declares one.

pub fn track_id(&self) -> Option<ElementId>
View source
indicator_idpub fn indicator_id(&self) -> Option<ElementId>—

Stable identity of the indicator part, when this meter declares one.

pub fn indicator_id(&self) -> Option<ElementId>
View source
current_valuepub const fn current_value(&self) -> f64—

Configures current value for this part.

pub const fn current_value(&self) -> f64
View source
minimumpub const fn minimum(&self) -> f64—

Configures minimum for this part.

pub const fn minimum(&self) -> f64
View source
maximumpub const fn maximum(&self) -> f64—

Configures maximum for this part.

pub const fn maximum(&self) -> f64
View source
low_valuepub const fn low_value(&self) -> Option<f64>—

Configures low value for this part.

pub const fn low_value(&self) -> Option<f64>
View source
high_valuepub const fn high_value(&self) -> Option<f64>—

Configures high value for this part.

pub const fn high_value(&self) -> Option<f64>
View source
optimum_valuepub const fn optimum_value(&self) -> Option<f64>—

Configures optimum value for this part.

pub const fn optimum_value(&self) -> Option<f64>
View source
completionpub fn completion(&self) -> f32—

The `0.0..=1.0` position of the value inside the meter's range.

pub fn completion(&self) -> f32
View source
is_lowpub fn is_low(&self) -> bool—

Whether the value falls at or below [`Self::low`].

pub fn is_low(&self) -> bool
View source
is_highpub fn is_high(&self) -> bool—

Whether the value falls at or above [`Self::high`].

pub fn is_high(&self) -> bool
View source

Meter::root_with

View source
pub fn root_with(&self, root: Element) -> Element

Decorate an application-owned root without adding layout or appearance.

Meter::root

View source
pub fn root(&self) -> Element

Create the unstyled root part. Use [`Self::root_with`] to supply an existing element.

Meter::track_with

View source
pub fn track_with(&self, track: Element) -> Element

Decorate the caller-owned track that the fill is measured inside.

Meter::track

View source
pub fn track(&self) -> Element

Create the unstyled track part. Use [`Self::track_with`] to supply an existing element.

Meter::indicator_with

View source
pub fn indicator_with(&self, indicator: Element) -> Element

Hide an application-owned fill from the accessible name.

Meter::indicator

View source
pub fn indicator(&self) -> Element

Create the unstyled indicator part. Use [`Self::indicator_with`] to supply an existing element.

Meter::label_with

View source
pub fn label_with(&self, label: Element) -> Element

Assign the stable mounted label target the root points at.

Meter::label

View source
pub fn label(&self) -> Element

Create the unstyled label part. Use [`Self::label_with`] to supply an existing element.

Meter::value

View source
pub fn value(&self) -> Element

Assign the stable mounted value target the root points at. Create the unstyled value text part.

Meter::value_with

View source
pub fn value_with(&self, value: Element) -> Element
pub fn meter(value: f64, minimum: f64, maximum: f64) -> Element

Create an unstyled meter root. This shorthand is equivalent to `Meter::new(value, minimum, maximum).root_with(div())`.