<!--
{
  "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/LayoutProperties/stackOrientation",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI16LayoutPropertiesV16stackOrientationAA4AxisOSgvp"
  },
  "title" : "stackOrientation"
}
-->

# stackOrientation

The orientation of the containing stack-like container.

```
var stackOrientation: Axis?
```

## Discussion

Certain views alter their behavior based on the stack orientation
of the container that they appear in. For example, [`Spacer`](/documentation/SwiftUI/Spacer) and
[`Divider`](/documentation/SwiftUI/Divider) align their major axis to match that of their container.

Set the orientation for your custom layout container by returning a
configured [`LayoutProperties`](/documentation/SwiftUI/LayoutProperties) instance from your [`Layout`](/documentation/SwiftUI/Layout)
type’s implementation of the [`layoutProperties`](/documentation/SwiftUI/Layout/layoutProperties)
method. For example, you can indicate that your layout has a
[`Axis.vertical`](/documentation/SwiftUI/Axis/vertical) major axis:

```
extension BasicVStack {
    static var layoutProperties: LayoutProperties {
        var properties = LayoutProperties()
        properties.stackOrientation = .vertical
        return properties
    }
}
```

A value of `nil`, which is the default when you don’t specify a
value, indicates an unknown orientation, or that a layout isn’t
one-dimensional.

---

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)