<!--
{
  "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/ViewSpacing/union(_:edges:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI11ViewSpacingV5union_5edgesA2C_AA4EdgeO3SetVtF"
  },
  "title" : "union(_:edges:)"
}
-->

# union(_:edges:)

Gets a new value that merges the spacing preferences of another spacing
instance with this instance for a specified set of edges.

```
func union(_ other: ViewSpacing, edges: Edge.Set = .all) -> ViewSpacing
```

## Parameters

`other`

Another spacing preferences instance to merge with this one.

`edges`

The edges to merge. Edges that you don’t specify are
unchanged after the method completes.

## Return Value

A new view spacing preferences instance with the merged
values.

## Discussion

This method behaves like [`formUnion(_:edges:)`](/documentation/SwiftUI/ViewSpacing/formUnion(_:edges:)), except that it creates
a copy of the original spacing preferences instance before merging,
leaving the original instance unmodified.

---

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)