Function spacer

Source
pub fn spacer(args: impl Into<SpacerArgs>)
Expand description

A component that inserts an empty, flexible space into a layout.

The spacer component is commonly used to add gaps between other UI elements, or to create flexible layouts where certain areas expand to fill available space. The behavior of the spacer is controlled by the SpacerArgs parameter, which allows you to specify fixed or flexible sizing for width and height using DimensionValue.

  • Use DimensionValue::Fixed for a fixed-size spacer.
  • Use DimensionValue::Fill to make the spacer expand to fill available space in its parent container.

§Example

use tessera_ui_basic_components::{
    row::{row_ui, RowArgs},
    spacer::{spacer, SpacerArgs},
    text::text,
};

row_ui!(
    RowArgs::default(),
    || text("Left".to_string()),
    // This spacer will fill the available width, pushing "Right" to the end.
    || spacer(SpacerArgs::fill_width()),
    || text("Right".to_string()),
);

You can also use SpacerArgs::fill_both or SpacerArgs::fill_height for other layout scenarios.

§Parameters

  • args: Configuration for the spacer’s width and height. Accepts any type convertible to SpacerArgs.