Adaptive Grids with LazyVGrid
Lay out cards in flexible grid columns.
Why a Grid?
Stacks give you rows or columns, but a LazyVGrid arranges items into neat rows and columns, like a photo album. 🖼️
Define the Columns
A LazyVGrid needs a columns array of GridItem values that describe how many tracks to lay out.
let columns = [GridItem(), GridItem()]
LazyVGrid(columns: columns) {
ForEach(items) { Cell($0) }
}All lessons in this course
- Horizontal & Vertical ScrollView
- LazyVStack & LazyHStack
- Adaptive Grids with LazyVGrid
- ScrollView Reader & Anchors