absolute_fill
absolute_fill(...) is a small helper that wraps one child in an AbsoluteFill layout node.
In plain language, it tells the runtime, "give this child the same width and height as the parent bounds." That makes it useful for scrims, loading overlays, full-surface backgrounds, and any layered content that should cover the whole stack.
Use it when the child should fill an existing layered area. Do not reach for it when you only need ordinary full-width layout in a Row, Column, or Container; those cases are better handled with normal box constraints, flex, or padding.
Example
A common pattern is a dimming scrim behind a modal or popover.
use fission::core::ui::{Container, Text, ZStack};
use fission::prelude::*;
let node = ZStack {
children: vec![
Text::new("Main content").into_node(),
absolute_fill(
Container::new(Text::new("").into_node())
.bg(fission::core::op::Color {
r: 0,
g: 0,
b: 0,
a: 140,
})
.into_node(),
),
],
..Default::default()
}
.into_node();
The helper does not add styling or input behavior by itself. It only changes sizing. In this example, the Container provides the background color while absolute_fill(...) makes that container cover the whole stacked area.
Field table
| Field | Type | Meaning | Notes / default behavior |
|---|---|---|---|
child | Node | The node that should fill the parent's bounds. | Required. The helper returns a new Node rather than a widget struct with public fields. |
Behavior and advice
absolute_fill(...) is most useful inside layered layouts such as ZStack or widgets that already build a stack internally, such as Overlay. The layout engine treats AbsoluteFill specially and gives the child tight constraints equal to the available parent size.
If you need an anchored overlay such as "top-right badge" or "bottom sheet handle," use Positioned instead. If you need more than one layer and explicit painting order, use ZStack.
A good rule is simple: use absolute_fill(...) when the child should cover everything, and use Positioned when the child should sit at a specific edge or corner.
Related
Overlay, Positioned, and ZStack.