---
title: "init(alignment:horizontalSpacing:verticalSpacing:)"
framework: swiftui
role: symbol
role_heading: Initializer
path: "swiftui/gridlayout/init(alignment:horizontalspacing:verticalspacing:)"
---

# init(alignment:horizontalSpacing:verticalSpacing:)

Creates a grid with the specified spacing and alignment.

## Declaration

```swift
nonisolated init(alignment: Alignment = .center, horizontalSpacing: CGFloat? = nil, verticalSpacing: CGFloat? = nil)
```

## Parameters

- `alignment`: The guide for aligning subviews within the space allocated for a given cell. The default is doc://com.apple.SwiftUI/documentation/SwiftUI/Alignment/center.
- `horizontalSpacing`: The horizontal distance between each cell, given in points. The value is nil by default, which results in a default distance between cells that’s appropriate for the platform.
- `verticalSpacing`: The vertical distance between each cell, given in points. The value is nil by default, which results in a default distance between cells that’s appropriate for the platform.
