<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/ZStack/init(alignment:spacing:content:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI6ZStackVAAE9alignment7spacing7contentACyAA0C9Content3DVyqd__GGAA9AlignmentV_14CoreFoundation7CGFloatVSgqd__yXEtcAIRszAA4ViewRd__lufc"
  },
  "title" : "init(alignment:spacing:content:)"
}
-->

# init(alignment:spacing:content:)

Creates an instance with the given spacing and alignment.

```
nonisolated init<V>(alignment: Alignment = .center, spacing: CGFloat?, @ContentBuilder content: () -> V) where Content == ZStackContent3D<V>, V : View
```

## Parameters

`alignment`

The guide for aligning the subviews in this stack on both the x- and y-axes.

`spacing`

The distance between adjacent subviews, or `nil` if you want the stack to
choose a default distance for each pair of subviews.

`content`

A content builder that creates the content of this stack.

---

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)