Skip to main content

root_style

Function root_style 

Source
pub fn root_style() -> Style
Expand description

The taffy style of the root container: a column that fills the window.

reserve_available_space tells the layout engine how much room there is, but it leaves the root node’s own size at auto, so taffy would size that node by its content. Two things go wrong then. A <View grow={1.0} justify="center"> child finds no free space to grow into and nothing to be centred in, so the app sits in the window’s top-left corner. And a child too wide to fit never has to shrink, because a content-sized parent simply grows with it and there is no overflow to resolve — the row runs off the right edge instead of grow and flex-shrink sharing out what there is.

So both sides are fixed at 100%: a window is exactly as big as it is. The height used to be only a minimum of 100%, so that a column taller than the window would lay out at its own height. That let a leaf_fill (a <ScrollArea>, a <VirtualList>) push the root past the window: such a leaf reports the whole root height as its content size, so a column of “a header, then a list that fills the rest” measured as header plus window, and the root grew to fit — the list’s last rows sat below the window edge. With a definite height the header keeps its content height (a flex item’s automatic minimum) and the list gets what is left. Content taller than the window still overflows it rather than being shrunk, for the same reason, and belongs in a ScrollArea as it always did.

Exposed so a runner, a test or an element that roots a tree of its own (<Overlay>) all use the same style.