---
title: "init(alignment:spacing:)"
framework: swiftui
role: symbol
role_heading: Initializer
path: "swiftui/hstacklayout/init(alignment:spacing:)"
---

# init(alignment:spacing:)

Creates a horizontal stack with the specified spacing and vertical alignment.

## Declaration

```swift
init(alignment: VerticalAlignment = .center, spacing: CGFloat? = nil)
```

## Parameters

- `alignment`: The guide for aligning the subviews in this stack. It has the same vertical screen coordinate for all subviews.
- `spacing`: The distance between adjacent subviews. Set this value to nil to use default distances between subviews.
