<!--
{
  "availability" : [
    "iOS: 13.0.0 -",
    "iPadOS: 13.0.0 -",
    "macCatalyst: 13.0.0 -",
    "macOS: 10.15.0 -",
    "tvOS: 13.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 6.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/compositingGroup()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE16compositingGroupQryF"
  },
  "title" : "compositingGroup()"
}
-->

# compositingGroup()

Wraps this view in a compositing group.

```
nonisolated func compositingGroup() -> some View
```

## Return Value

A view that wraps this view in a compositing group.

## Discussion

A compositing group makes compositing effects in this view’s ancestor
views, such as opacity and the blend mode, take effect before this view
is rendered.

Use `compositingGroup()` to apply effects to a parent view before
applying effects to this view.

In the example below the `compositingGroup()` modifier separates the
application of effects into stages. It applies the [`opacity(_:)`](/documentation/SwiftUI/View/opacity(_:))
effect to the VStack before the `blur(radius:)` effect is applied to the
views inside the enclosed [`ZStack`](/documentation/SwiftUI/ZStack). This limits the scope of the
opacity change to the outermost view.

```
VStack {
    ZStack {
        Text("CompositingGroup")
            .foregroundColor(.black)
            .padding(20)
            .background(Color.red)
        Text("CompositingGroup")
            .blur(radius: 2)
    }
    .font(.largeTitle)
    .compositingGroup()
    .opacity(0.9)
}
```

![A view showing the effect of the compositingGroup modifier in applying](images/com.apple.SwiftUI/SwiftUI-View-compositingGroup@2x.png)

---

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)