UniversalGlassEffectContainer orchestrates multiple glass effects so they render as one fused surface on earlier OS releases while deferring to SwiftUI's native GlassEffectContainer on OS 26.
@Namespace private var ns
UniversalGlassEffectContainer {
HStack {
AvatarView()
.universalGlassEffect()
.universalGlassEffectUnion(id: "profile", namespace: ns)
DetailsView()
.universalGlassEffect()
.universalGlassEffectUnion(id: "profile", namespace: ns)
}
}UniversalGlassEffectContainer(spacing:rendering:content:).automaticor.glassrenders the native container whenever it exists.materialforces the legacy renderer even on OS 26+, useful for testing or when you prefer the material aesthetic everywhere
When the native container is unavailable, the helper swaps in FallbackGlassEffectContainerRenderer. The renderer:
- Projects every child's anchor preference (registered by
universalGlassEffect) into concrete frames - Groups participants by shared union keys or effect IDs so neighbouring elements "melt" into a single slab
- Draws a
GlassEffectFallbackOverlaytwice—once as a background and once as a mask—so the merged plate perfectly clips the child content
This setup guarantees that the fallback honours matched-geometry unions, respects per-view shapes, and keeps hit-testing consistent.
The container works hand-in-hand with:
View.universalGlassEffectUnion(id:namespace:rendering:)
View.universalGlassEffectID(_:in:rendering:)
View.universalGlassEffectTransition(_:)Each helper goes straight to SwiftUI's implementation on new OS builds and otherwise stores metadata in the environment for the fallback renderer to consume.
- For the full breakdown of the participant pipeline, grouping keys, and overlay drawing order, see Container Internals
- On pre-OS 26 systems, the fallback
UniversalGlassEffectContainerignores thespacingparameter