Skip to content

rguillen-dev/LiquidGlass

Repository files navigation

LiquidGlass

A SwiftUI modifier that brings Apple's iOS 26 Liquid Glass material to any view, with a high-fidelity fallback for iOS 17 and 18.

Swift iOS SPM License

LiquidGlass Demo

Preview

Styles Components
Styles tab Components tab

Installation

Package.swift

dependencies: [
    .package(url: "https://github.com/rguillen-dev/LiquidGlass.git", from: "0.1.0")
],
targets: [
    .target(
        name: "YourTarget",
        dependencies: ["LiquidGlass"]
    )
]

Xcode

File ▸ Add Package Dependencies… and paste:

https://github.com/rguillen-dev/LiquidGlass.git

Demo app

A runnable iOS demo lives at DemoApp/. Open DemoApp/LiquidGlassDemo.xcodeproj in Xcode and hit ⌘R — the project pulls in the local LiquidGlass package from this repo via a relative path, so no remote checkout is needed. Bundle ID dev.ricardoguillen.LiquidGlassDemo, minimum deployment iOS 17.0.

Quick start

import SwiftUI
import LiquidGlass

struct NowPlayingCard: View {
    var body: some View {
        VStack(alignment: .leading) {
            Text("Now Playing").font(.headline)
            Text("Synthwave Drive").font(.subheadline)
        }
        .padding()
        .glass(style: .card, tint: .indigo)
    }
}

Use the prebuilt components when you want a complete surface:

GlassCard(tint: .blue) {
    Text("Hello, glass.")
}

GlassButton(tint: .pink) {
    // action
} label: {
    Label("Continue", systemImage: "arrow.right")
}

API reference

.glass(style:tint:cornerRadius:)

Parameter Type Default Description
style GlassStyle .sheet Visual variant. Controls thickness, depth, and default corner radius.
tint Color? nil Low-opacity color overlay applied on top of the material.
cornerRadius CGFloat? nil Overrides the style's default corner radius when provided.

GlassStyle

Case Role Default corner radius
.sheet Floating panel, prominent depth 24
.card Contained surface, medium depth 16
.button Compact, interactive feel 12
.toolbar Inline bar element 10
.sidebar Full-height navigation surface 20
.overlay Full coverage, max blur 0

Components

Type Description
GlassCard Container that wraps content with padding and the glass material.
GlassButton Button styled with the glass material and a press-state animation.

Fallback behavior

On iOS 26 and later, LiquidGlass uses Apple's native glassEffect(_:in:) API directly.

On iOS 17 and 18, the package renders a hand-tuned approximation:

  • A Material base layer chosen per style (.ultraThinMaterial for .sheet, .thickMaterial for .sidebar, and so on)
  • A 0.5 pt inner stroke at 10–20% white opacity to simulate refracting glass
  • A per-style depth shadow that scales with the role of the surface
  • Optional tint, layered as a low-opacity fill above the material

The result reads as glass on every supported OS — your UI keeps the same intent whether it ships on iOS 17 or iOS 26.

Accessibility

The native iOS 26 path inherits Reduce Transparency and Reduce Motion from the system automatically. The iOS 17–18 fallback reads these settings itself:

  • Reduce Transparency — the surface drops its translucent material for an opaque fill and raises the inner-stroke contrast.
  • Reduce MotionGlassButton disables its press scale/bounce animation, keeping only an instantaneous opacity dim as press feedback.

Requirements

  • Swift 6.0+
  • iOS 17.0+
  • Xcode 16.0+ (Xcode 26+ recommended for native Liquid Glass rendering)

License

MIT — see LICENSE.


Built by Ricardo Guillen · ricardoguillen.dev

About

SwiftUI modifier for Apple's Liquid Glass material — iOS 26+

Topics

Resources

License

Stars

1 star

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages