Skip to content

Meter

Show a finite measurement within explicit bounds.

On this page

Available with egui, Masonry and GPUI through the same public component API. Platform input and accessibility coverage still have alpha limits.

Usage

Replace src/App.iru in a scaffolded project with this complete file, then run cargo run. Keep the scaffold's main.rs and build.rs; this file includes its state, handlers and scoped styles.

src/App.iru
<view>
    <Column class="example">
        <Meter label="Temperature" value={temperature} min={-10.0} max={40.0} class="range" />
        <Text text={format!("Temperature: {} C", temperature)} />
        <Row class="actions">
            <Button text="Cool down" @click={cool} />
            <Button text="Warm up" @click={warm} class="action" />
        </Row>
    </Column>
</view>
<rust>
use inrux::prelude::*;

let temperature: f64 = 20.0;

/// Clamp changes to the meter's lower bound.
fn cool(state: &mut State, _: &Context<State>) {
    state.temperature = (state.temperature - 5.0).max(-10.0);
}
/// Clamp changes to the meter's upper bound.
fn warm(state: &mut State, _: &Context<State>) {
    state.temperature = (state.temperature + 5.0).min(40.0);
}
</rust>
<style scoped>
.example {
    padding: 24px;
    gap: 16px;
}
.actions {
    gap: 8px;
}
.action {
    background: #b84200;
    color: white;
    padding: 12px;
    border-radius: 6px;
}
.action:hover {
    background: #913400;
}
.action:focus-visible {
    border-width: 2px;
    border-color: #262626;
}
.range {
    height: 16px;
    accent-color: #b84200;
}
</style>

API Reference

Props

PropTypeDefaultDescription
labelString-like expressionRequiredNonempty description of the measurement.
valuef64RequiredFinite measurement, normalized to the declared range.
minf64RequiredFinite lower bound, strictly below max.
maxf64RequiredFinite upper bound, strictly above min.

Common props

PropTypeDefaultDescription
idString-like expressionNot setStyle-selector identity; independent of retained mount identity.
classString-like expressionNot setWhitespace-separated stylesheet classes.
styleStyleNot setExplicit Rust style overrides for this node.
keyString-like expressionNot setRetained sibling identity; preserve it while reordering children.
widthSizeComponent styleExplicit width constraint; otherwise use the resolved style.
heightSizeComponent styleExplicit height constraint; otherwise use the resolved style.
paddingf32Component styleUniform padding in logical pixels; otherwise use the resolved style.
gapf32Component styleChild spacing in logical pixels; otherwise use the resolved style.

“Component style” means the attribute is omitted and the normal style cascade supplies the value. Application styles can override framework defaults.

Emits

EventPayloadDescription
——No component events are emitted.

Behavior

Use Meter for a measurement and Progress for completion. Value must lie between min and max. Invalid ranges return a configuration error. This is not a draggable slider.

Styling and limits

Style the track at the root and the fill through ::part(indicator). Borders, size and accent follow the shared style contract.

Read the detailed reference for validation and native integration details. The playgrounds include a working Meter specimen with its surrounding state and reset controls.

Inrux · Built with Nuxt Content, IPEX, and Akaza UI.