# Grid

Grid is a new container view that arranges views in a two-dimensional grid.&#x20;

Grid will measure its subviews up front to enable cells that span multiple columns and enable automatic alignments across rows and columns.

This particular grid view contains two GridRow instances.\
Within a row, each view corresponds to a column.<br>

🔥 In `contentView` add a second tab&#x20;

// Create a Grid View

**import** Charts

**import** SwiftUI

<br>

**struct** ContentView: View {

&#x20;   @State **private** **var** selection = 2

&#x20;  &#x20;

&#x20;   **var** body: **some** View {

&#x20;       TabView(selection: $selection) {

&#x20;           WinesTab()

&#x20;               .tabItem {

&#x20;                   Label("Wines", systemImage: "chart.bar.doc.horizontal")

&#x20;               }

&#x20;               .tag(1)

&#x20;           <mark style="color:orange;">Grid {</mark>

&#x20;               <mark style="color:orange;">GridRow {</mark>

&#x20;                   <mark style="color:orange;">ParisDetailsChart()</mark>

&#x20;                       <mark style="color:orange;">.gridCellColumns(2)</mark>

&#x20;               <mark style="color:orange;">}</mark>

&#x20;               <mark style="color:orange;">GridRow {</mark>

&#x20;                   <mark style="color:orange;">AmsterdamDetailsChart()</mark>

&#x20;                   <mark style="color:orange;">SalesDetailsChart()</mark>

&#x20;               <mark style="color:orange;">}</mark>

&#x20;           <mark style="color:orange;">}</mark>

&#x20;               <mark style="color:orange;">.tabItem {</mark>

&#x20;                   <mark style="color:orange;">Label("Overview", systemImage: "square.grid.2x2")</mark>

&#x20;               <mark style="color:orange;">}</mark>

&#x20;               <mark style="color:orange;">.tag(2)</mark>

&#x20;       }

&#x20;   }

}

<br>

**struct** ContentView\_Previews: PreviewProvider {

&#x20;   **static** **var** previews: **some** View {

&#x20;       ContentView()

&#x20;   }

}

```swift
// Example

struct WeatherDetailView: View {
    var body: some View {
        Grid {
            GridRow {
                NameHeadLine()
                    .gridCellColumns(2)
            }
            GridRow {
                CalendarIcon()
                SymbolGrid()
            }
        }
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://betty-dev.gitbook.io/cutting-edge-swiftui-apps/start-with-layout/grid.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
