Expand description
MaxSize — a layout modifier that caps a child to a maximum width and/or height.
The child is proposed the lesser of the parent’s proposal and the configured maximum on each axis; the reported size is then clamped again so a child that intrinsically overshoots the cap is always contained. Axes with no maximum set are passed through unchanged.
MaxSize clips its child when a maximum is active (clips_children() == true)
so content that still overflows after layout does not bleed into adjacent widgets.
Maximum values can be static or bound to a reactive Signal<f32>
for animated or data-driven constraints.
For the inverse operation (ensuring a minimum size) see MinSize.
// Cap a text widget to 240 logical pixels wide.
let _w = MaxSize::width(240.0)
.child(TextWidget::new(lit!("This text will not exceed 240 dp.")));Structs§
- MaxSize
- Layout modifier that enforces a maximum width and/or height on a single child widget.