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

# spacing

The subviews’s preferred spacing values.

```
var spacing: ViewSpacing { get }
```

## Discussion

This [`ViewSpacing`](/documentation/SwiftUI/ViewSpacing) instance indicates how much space a subview
in a custom layout prefers to have between it and the next view.
It contains preferences for all edges, and might take into account
the type of both this and the adjacent view. If your [`Layout`](/documentation/SwiftUI/Layout) type
places subviews based on spacing preferences, use this instance
to compute a distance between this subview and the next. See
[`placeSubviews(in:proposal:subviews:cache:)`](/documentation/SwiftUI/Layout/placeSubviews(in:proposal:subviews:cache:)) for an
example.

You can also merge this instance with instances from other subviews
to construct a new instance that’s suitable for the subviews’ container.
See [`spacing(subviews:cache:)`](/documentation/SwiftUI/Layout/spacing(subviews:cache:)).

---

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)