Skip to main content

flow_row

Function flow_row 

Source
pub fn flow_row() -> FlowRowBuilder
Expand description

§flow_row

A layout component that wraps children into multiple horizontal rows.

§Usage

Wrap chips, tags, or button groups to fit variable-width screens.

§Parameters

  • modifier — modifier chain applied to the flowing row container.
  • main_axis_alignment — alignment within each wrapped line.
  • cross_axis_alignment — cross-axis alignment for items inside a line.
  • line_alignment — alignment between wrapped lines.
  • item_spacing — spacing between items in the same line.
  • line_spacing — spacing between wrapped lines.
  • max_items_per_line — optional cap for items per line.
  • max_lines — optional cap for total wrapped lines.
  • children — child slot rendered inside the layout.

§Examples

use tessera_components::{boxed::boxed, flow_row::flow_row, modifier::{ModifierExt as _, SemanticsArgs}};
use tessera_ui::{Dp, Modifier, tessera, testing::layout_test};

#[tessera]
fn demo() {
    flow_row().modifier(Modifier::new().width(Dp(50.0))).children(|| {
        for tag in ["first", "second"] {
            boxed().modifier(
                Modifier::new().size(Dp(30.0), Dp(10.0))
                    .semantics(SemanticsArgs { test_tag: Some(tag.into()), ..Default::default() })
            ).children(|| {});
        }
    });
}

let snapshot = layout_test(demo).viewport_px(50, 100).run();
snapshot.node("first").position(0, 0).size(30, 10);
snapshot.node("second").position(0, 10).size(30, 10);