---
title: "glassBackgroundEffect(displayMode:)"
framework: swiftui
role: symbol
role_heading: Instance Method
path: "swiftui/view/glassbackgroundeffect(displaymode:)"
---

# glassBackgroundEffect(displayMode:)

Fills the view’s background with an automatic glass background effect and container-relative rounded rectangle shape.

## Declaration

```swift
nonisolated func glassBackgroundEffect(displayMode: GlassBackgroundDisplayMode = .always) -> some View

```

## Parameters

- `displayMode`: When to display the glass background. The default is doc://com.apple.SwiftUI/documentation/SwiftUI/GlassBackgroundDisplayMode/always.

## Return Value

Return Value A view with a glass background.

## Discussion

Discussion Use this modifier to add a 3D glass background material that includes thickness, specularity, glass blur, shadows, and other effects. Because of its physical depth, the glass background influences z-axis layout. To ensure that the effect renders properly when you add it to a collection of views in a ZStack, add the modifier to the stack rather to one of the views in the stack. This includes when you create an implicit stack with view modifiers like overlay(alignment:content:) or background(alignment:content:). In those cases, you might need to create an explicit ZStack inside the content closure to have a place to add the glass background modifier.

## See Also

### Adding a glass background on views in visionOS

- [glassBackgroundEffect(in:displayMode:)](swiftui/view/glassbackgroundeffect(in:displaymode:).md)
- [GlassBackgroundDisplayMode](swiftui/glassbackgrounddisplaymode.md)
- [GlassBackgroundEffect](swiftui/glassbackgroundeffect.md)
- [AutomaticGlassBackgroundEffect](swiftui/automaticglassbackgroundeffect.md)
- [GlassBackgroundEffectConfiguration](swiftui/glassbackgroundeffectconfiguration.md)
- [FeatheredGlassBackgroundEffect](swiftui/featheredglassbackgroundeffect.md)
- [PlateGlassBackgroundEffect](swiftui/plateglassbackgroundeffect.md)
