Two-dimensional grids and adaptive containers — iOS-only extensions to the layout system
These layout containers extend the core stack primitives with two-dimensional and adaptive behavior, and are currently iOS-only. Grid arranges children in a row-and-column matrix, with GridRow defining each row. ViewThatFits picks the first of several alternative layouts that fits the available space, useful for responsive designs without a manual geometry reader.
Grid determines the number of columns from the row with the most children. Rows with fewer children leave trailing cells empty. Use Divider directly as a child (not inside a GridRow) to insert a horizontal separator that spans the full grid width. Grid cell modifiers (.gridCellColumns(), .gridCellAnchor(), .gridCellUnsizedAxes(), .gridColumnAlignment()) control individual cell layout behavior.
The vertical alignment of cells in this row. One of "top", "center", "bottom", "firstTextBaseline", or "lastTextBaseline". Overrides the grid-level alignment for this row.
GridRow must be a direct child of Grid. Using GridRow outside a Grid has no effect. The number of children in the widest GridRow determines the column count for the entire grid. Apply .gridCellColumns(), .gridCellAnchor(), or .gridCellUnsizedAxes() to individual children to control cell layout.
Children are tested in order. The first child whose ideal size fits within the available space is rendered; all others are discarded. If no child fits, the last child is used as the fallback. This is useful for building responsive layouts that adapt to different screen sizes without using GeometryReader.