<!--
{
  "availability" : [
    "iOS: 26.0.0 -",
    "iPadOS: 26.0.0 -",
    "macCatalyst: 26.0.0 -",
    "macOS: 26.0.0 -",
    "tvOS: 26.0.0 -",
    "watchOS: 26.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/glassEffectTransition(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE21glassEffectTransitionyQrAA05GlasseF0VF"
  },
  "title" : "glassEffectTransition(_:)"
}
-->

# glassEffectTransition(_:)

Associates a glass effect transition with any
glass effects defined within this view.

```
@MainActor @preconcurrency func glassEffectTransition(_ transition: GlassEffectTransition) -> some View
```

## Discussion

You use this modifier with the [`glassEffect(_:in:)`](/documentation/SwiftUI/View/glassEffect(_:in:))
view modifier and [`GlassEffectContainer`](/documentation/SwiftUI/GlassEffectContainer) view. When used together,
SwiftUI will use the provided transition to apply changes to
the glass effect when you add or remove views with
these effects from the view hierarchy.

In the example below, the notepad image will transition into and out
of the pencil image when the isExpanded variable changes.

```
var isExpanded: Bool
@Namespace private var namespace

var body: some View {
    GlassEffectContainer(spacing: 10.0) {
        HStack(spacing: 10.0) {
            Image(systemName: "pencil")
                .frame(width: 20.0, height: 20.0)
                .glassEffect()
                .glassEffectID("pencil", in: namespace)

                if isExpanded {
                    Image(systemName: "note")
                        .frame(width: 20.0, height: 20.0)
                        .glassEffect()
                        .glassEffectID("note", in: namespace)
                        .glassEffectTransition(.matchedGeometry)
                }
            }
        }
    }
}
```

---

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)