<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 2.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "SwiftUI",
  "identifier" : "/documentation/SwiftUI/View/glassBackgroundEffect(_:in:displayMode:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE21glassBackgroundEffect_2in11displayModeQrqd_0__qd__AA05Glasse7DisplayI0OtAA15InsettableShapeRd__AA0jeF0Rd_0_r0_lF"
  },
  "title" : "glassBackgroundEffect(_:in:displayMode:)"
}
-->

# glassBackgroundEffect(_:in:displayMode:)

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

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

## Parameters

`effect`

A [`GlassBackgroundEffect`](/documentation/SwiftUI/GlassBackgroundEffect) instance that SwiftUI uses to
the fill the background shape that you specify.

`shape`

An [`InsettableShape`](/documentation/SwiftUI/InsettableShape) instance that SwiftUI draws behind
the view.

`displayMode`

When to display the glass background. The default is
[`GlassBackgroundDisplayMode.always`](/documentation/SwiftUI/GlassBackgroundDisplayMode/always).

## Return Value

A view with a glass background.

---

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)