Expand description
Padding — a single-child layout container that adds insets around its child.
Padding shrink-wraps a child widget and enlarges it by configurable insets
on each of the four sides. Horizontal insets are leading/trailing
(logical), not left/right (physical), so they flip automatically in RTL
locales. Each inset accepts a static f32 or a reactive Signal<f32>; a
bound inset schedules a relayout whenever the signal fires, so theme-derived
spacing values take effect without rebuilding the widget tree.
The grow weight, shrink weight, and compression floor reported by the child
are forwarded through the padding so a flexible or shrinkable child inside a
Padding stays flexible or shrinkable from the parent’s perspective.
§When to use
- Adding whitespace around a widget without wrapping it in a stack.
- Applying asymmetric insets (e.g. extra leading inset for a list item).
- Reacting to a
Signal-driven spacing token.
Use Padding::uniform when all four sides are equal, and
Padding::symmetric when horizontal and vertical insets differ.
// 12 dp padding on every side:
let _w = Padding::uniform(12.0)
.child(TextWidget::new(lit!("Hello")));Structs§
- Padding
- A layout container that adds padding (insets) around a single child.