<!--
{
  "availability" : [
    "iOS: 16.0.0 -",
    "iPadOS: 16.0.0 -",
    "macCatalyst: 16.0.0 -",
    "macOS: 13.0.0 -",
    "tvOS: 16.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 9.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/GridRow",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI7GridRowV"
  },
  "title" : "GridRow"
}
-->

# GridRow

A horizontal row in a two dimensional grid container.

```
@frozen struct GridRow<Content> where Content : View
```

## Overview

Use one or more `GridRow` instances to define the rows of a [`Grid`](/documentation/SwiftUI/Grid)
container. The child views inside the row define successive grid cells.
You can add rows to the grid explicitly, or use the [`ForEach`](/documentation/SwiftUI/ForEach) structure
to generate multiple rows. Similarly, you can add cells to the row
explicitly or you can use [`ForEach`](/documentation/SwiftUI/ForEach) to generate multiple cells inside
the row. The following example mixes these strategies:

```
Grid {
    GridRow {
        Color.clear
            .gridCellUnsizedAxes([.horizontal, .vertical])
        ForEach(1..<4) { column in
            Text("C\(column)")
        }
    }
    ForEach(1..<4) { row in
        GridRow {
            Text("R\(row)")
            ForEach(1..<4) { _ in
                Circle().foregroundStyle(.mint)
            }
        }
    }
}
```

The grid in the example above has an explicit first row and three generated
rows. Similarly, each row has an explicit first cell and three generated
cells:

![A screenshot of a grid that contains four rows and four columns. Scanning](images/com.apple.SwiftUI/GridRow-1-iOS~dark@2x.png)

To create an empty cell, use something invisible, like the
[`clear`](/documentation/SwiftUI/ShapeStyle/clear) color that appears in the first column of the first
row in the example above. However, if you use a flexible view like a
[`Color`](/documentation/SwiftUI/Color) or a [`Spacer`](/documentation/SwiftUI/Spacer), you might also need to add the
[`gridCellUnsizedAxes(_:)`](/documentation/SwiftUI/View/gridCellUnsizedAxes(_:)) modifier to prevent the view from
taking up more space than the other cells in the row or column need.

> Important: You can’t use ``doc://com.apple.SwiftUI/documentation/SwiftUI/EmptyView`` to create a blank cell because
> that resolves to the absence of a view and doesn’t generate a cell.

By default, the cells in the row use the [`Alignment`](/documentation/SwiftUI/Alignment) that you define
when you initialize the [`Grid`](/documentation/SwiftUI/Grid). However, you can override the vertical
alignment for the cells in a row by providing a [`VerticalAlignment`](/documentation/SwiftUI/VerticalAlignment)
value to the row’s [`init(alignment:content:)`](/documentation/SwiftUI/GridRow/init(alignment:content:)) initializer.

If you apply a view modifier to a row, the row applies the modifier to
all of the cells, similar to how a [`Group`](/documentation/SwiftUI/Group) behaves. For example,  if
you apply the [`border(_:width:)`](/documentation/SwiftUI/View/border(_:width:)) modifier to a row, SwiftUI draws
a border on each cell in the row rather than around the row.

## Topics

### Creating a grid row

[`init(alignment:content:)`](/documentation/SwiftUI/GridRow/init(alignment:content:))

Creates a horizontal row of child views in a grid.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)
