These layout containers extend the core stack primitives with two-dimensional and adaptive behavior, and are currently iOS-only.Documentation Index
Fetch the complete documentation index at: https://docs.metabind.ai/llms.txt
Use this file to discover all available pages before exploring further.
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
Arranges children in a two-dimensional grid of rows and columns.An array of GridRow components. Each GridRow defines one row in the grid. The number of columns is determined by the row with the most children.
Configuration options for the grid.
.gridCellColumns() modifier to span a cell across multiple columns:
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.GridRow
Defines a row of cells within a Grid layout.An array of components, one per column cell. Each child aligns with the corresponding column in the parent Grid.
Configuration options for the row.
.gridCellColumns() on a child to span multiple columns:
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.ViewThatFits
Picks the first child that fits in the available space for adaptive layouts.An array of alternative layouts, ordered from most preferred to least preferred. The first child that fits in the available space is rendered.
Configuration options.
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.
See also
- VStack — vertical stack
- HStack — horizontal stack
- GeometryReader — manual geometry-based layout
- Alignment — alignment values for grid cells
- Axis — axis values for fit testing