<!--
{
  "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/glassEffect(_:in:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:7SwiftUI4ViewPAAE11glassEffect_2inQrAA5GlassV_qd__tAA5ShapeRd__lF"
  },
  "title" : "glassEffect(_:in:)"
}
-->

# glassEffect(_:in:)

Applies the Liquid Glass effect to a view.

```
nonisolated func glassEffect(_ glass: Glass = .regular, in shape: some Shape = DefaultGlassEffectShape()) -> some View
```

## Discussion

When you use this effect, the system:

- Renders a shape anchored behind a view with the Liquid Glass material.
- Applies the foreground effects of Liquid Glass over a view.

For example, to add this effect to a [`Text`](/documentation/SwiftUI/Text):

```swift
Text("Hello, World!")
    .font(.title)
    .padding()
    .glassEffect()
```

SwiftUI uses the [`regular`](/documentation/SwiftUI/Glass/regular) variant by default along with a [`Capsule`](/documentation/SwiftUI/Capsule)
shape.

SwiftUI anchors the Liquid Glass to a view’s bounds. For the example
above, the material fills the entirety of the `Text`
frame, which includes the padding.

You typically use this modifier with a [`GlassEffectContainer`](/documentation/SwiftUI/GlassEffectContainer)
to combine multiple Liquid Glass shapes into a single shape that
can morph into one another.

---

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)