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

# glassBackgroundEffect(_:in:displayMode:)

Fills the view’s background with a custom glass background effect and a shape that you specify.

## Declaration

```swift
nonisolated func glassBackgroundEffect<T, S>(_ effect: S, in shape: T, displayMode: GlassBackgroundDisplayMode = .always) -> some View where T : InsettableShape, S : GlassBackgroundEffect

```

## Parameters

- `effect`: A doc://com.apple.SwiftUI/documentation/SwiftUI/GlassBackgroundEffect instance that SwiftUI uses to the fill the background shape that you specify.
- `shape`: An doc://com.apple.SwiftUI/documentation/SwiftUI/InsettableShape instance that SwiftUI draws behind the view.
- `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.

## See Also

### Background elements

- [background(alignment:content:)](swiftui/view/background(alignment:content:).md)
- [background(_:ignoresSafeAreaEdges:)](swiftui/view/background(_:ignoressafeareaedges:).md)
- [background(ignoresSafeAreaEdges:)](swiftui/view/background(ignoressafeareaedges:).md)
- [background(_:in:fillStyle:)](swiftui/view/background(_:in:fillstyle:).md)
- [background(in:fillStyle:)](swiftui/view/background(in:fillstyle:).md)
- [alternatingRowBackgrounds(_:)](swiftui/view/alternatingrowbackgrounds(_:).md)
- [listRowBackground(_:)](swiftui/view/listrowbackground(_:).md)
- [scrollContentBackground(_:)](swiftui/view/scrollcontentbackground(_:).md)
- [containerBackground(_:for:)](swiftui/view/containerbackground(_:for:).md)
- [containerBackground(for:alignment:content:)](swiftui/view/containerbackground(for:alignment:content:).md)
- [glassBackgroundEffect(displayMode:)](swiftui/view/glassbackgroundeffect(displaymode:).md)
- [glassBackgroundEffect(_:displayMode:)](swiftui/view/glassbackgroundeffect(_:displaymode:).md)
- [glassBackgroundEffect(in:displayMode:)](swiftui/view/glassbackgroundeffect(in:displaymode:).md)
- [backgroundExtensionEffect()](swiftui/view/backgroundextensioneffect().md)
- [backgroundExtensionEffect(isEnabled:)](swiftui/view/backgroundextensioneffect(isenabled:).md)
