Skip to main content

layout

Function layout 

Source
pub fn layout() -> LayoutBuilder
Expand description

§layout

Emit an explicit layout node with a layout policy, render policy, modifier chain, and optional child slot.

§Usage

Build framework or internal components that need to define explicit layout and rendering behavior inside a tessera composition boundary.

§Parameters

  • layout_policy - pure layout policy used for measuring and placing the emitted layout node, defaulting to DefaultLayoutPolicy
  • render_policy - render policy used to record draw and compute commands for the emitted layout node, defaulting to NoopRenderPolicy
  • modifier - node-local modifier chain attached before child content is emitted, defaulting to an empty Modifier
  • child - optional child slot rendered as the emitted node’s content subtree

§Examples

use tessera_ui::{
    Modifier, NoopRenderPolicy, RenderSlot,
    layout::{DefaultLayoutPolicy, layout},
};

#[tessera_ui::tessera]
fn primitive_example(modifier: Modifier, child: RenderSlot) {
    layout()
        .layout_policy(DefaultLayoutPolicy)
        .render_policy(NoopRenderPolicy)
        .modifier(modifier)
        .child(move || child.render());
}