.glassEffect()

iOS 26+

Applies the Liquid Glass effect to a view, creating a translucent, frosted-glass appearance that adapts to light and dark mode.

Visual Effects
Official Apple Documentation →
iOS User Coverage
14.1%
coverage

14.1% of iOS users can use this modifier

Version Compatibility
iOS 26.1
10.7% Supported
iOS 26.2
2.0% Supported
iOS 26.0
1.3% Supported

iOS 26+ required

Variants
.glassEffect()

Applies default glass effect within a capsule shape

.glassEffect(in:)

Applies glass effect within a custom shape

Parameters:
  • shape: any Shape
.glassEffect(_:)

Applies glass effect with style customization

Parameters:
  • style: GlassEffectStyle
Code Examples

Basic Glass Effect

Apply a simple glass effect with default capsule shape

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

Glass Effect with Custom Shape

Use a rounded rectangle shape for the glass effect

Text("Hello, World!")
    .font(.title)
    .padding()
    .glassEffect(in: .rect(cornerRadius: 16.0))

Interactive Glass Effect with Tint

Create an interactive glass button with custom tint

Text("Hello, World!")
    .font(.title)
    .padding()
    .glassEffect(.regular.tint(.orange).interactive())

Conditional Availability (iOS 26+)

Use #available to support older iOS versions with a fallback

Text("Hello, World!")
    .font(.title)
    .padding()
    .background {
        if #available(iOS 26, *) {
            Color.clear
                .glassEffect()
        } else {
            // Fallback for iOS 18 and earlier
            RoundedRectangle(cornerRadius: 16)
                .fill(.ultraThinMaterial)
        }
    }

Loading related modifiers...

Using with Older iOS Versions

If your app supports iOS versions older than 26, you can use #available to conditionally apply this modifier:

if #available(iOS 26, *) {
    myView.glassEffect()
} else {
    // Fallback for older iOS versions
    myView
}

Check the code examples above for specific #available patterns with this modifier.

Frequently Asked Questions

What iOS version is required for .glassEffect()?

The .glassEffect() modifier requires iOS 26 or later. This means 14.1% of current iOS users can use this modifier.

Can I use this if my app supports older iOS versions?

Yes! Use #available(iOS 26, *) to conditionally apply this modifier only on devices running iOS 26 or later, with a fallback for older versions.

How do I use .glassEffect() in SwiftUI?

Apply the .glassEffect() modifier to any SwiftUI view. Check the code examples above for usage patterns.

Where can I learn more?

Visit the official Apple documentation for detailed information.

Explore More SwiftUI Modifiers