Skip to content

Spacer

Consume free main-axis space in a Row or Column.

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">
        <Checkbox label="Use a narrower row" model:checked={narrow} />
        <Row style={Style::new().max_width(Size::Px(content_width.get().unwrap_or(640.0)))} class="sample">
            <Text text="Left" width={Size::Content} />
            <Spacer />
            <Text text="Right" width={Size::Content} />
        </Row>
    </Column>
</view>
<rust>
use inrux::prelude::*;

let narrow: Signal<bool> = Signal::new(false);
let content_width_narrow = narrow.clone();
let content_width: Computed<f32> = Computed::new(move || {
    if content_width_narrow.get() {
        320.0
    } else {
        640.0
    }
});
</rust>
<style scoped>
.example {
    padding: 24px;
    gap: 16px;
}
.sample {
    padding: 16px;
    background: #f5f5f5;
}
</style>

API Reference

Props

This component has no component-specific props. It accepts these common attributes:

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

Spacer is childless, has zero intrinsic size and grows into available main-axis space. Several spacers share free space according to growth. A bounded Column can use it vertically. It cannot create extra space after the parent has exhausted its bounds.

Styling and limits

Use its growth and size constraints rather than adding artificial fixed margins. Spacer has no model, event or focus target.

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

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