Index of every page on this site: llms.txt
All skills
flowritescode avatar

/swiftui-liquid-glass

@3a6c74b
Run it yourself

Implement, review, and refactor SwiftUI features using the iOS 26+ Liquid Glass API. Use when adopting Liquid Glass in new UI, converting existing surfaces to glass, reviewing glass usage for correctness, or fixing common Liquid Glass pitfalls (custom blur stacks, scroll views, button shapes, bottom bars, pre-enclosed symbols).

Use this Skill: https://skilld.dev/gh/flowritescode/fwc-swiftui-skills/swiftui-liquid-glass

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

reference.md

≈1.9k tokens on demand. Your agent reads this file only when SKILL.md points to it.

Liquid Glass reference

Extended patterns for the swiftui-liquid-glass skill. Read when implementing morphing transitions, tuning container spacing, or choosing fallbacks.

API surface (iOS 26+)

API Purpose
.glassEffect(_:in:) Apply glass to any custom view
.buttonStyle(.glass) Neutral glass button
.buttonStyle(.glassProminent) Tinted glass button; pair with .tint(Color)
.buttonBorderShape(_:) Capsule, circle, rounded rect for button chrome
GlassEffectContainer Groups nearby glass for merge/morph
.glassEffectID(_:in:) Identity for morphing transitions
.glassEffectUnion(id:namespace:) Unite separate views into one glass blob
.safeAreaBar(_:) System bottom/top bar with blur behind content
.sharedBackgroundVisibility(_:) Hide shared glass on ToolbarContent (e.g. ToolbarItem)

Glass configuration

.glassEffect(.regular, in: .rect(cornerRadius: 16))
.glassEffect(.regular.tint(.orange), in: .capsule)
.glassEffect(.regular.interactive(), in: .circle)
  • .regular — default variant
  • .tint(Color) — color wash for prominence (not available as gradient on buttons via .glassProminent)
  • .interactive() — glass reacts to touch/pointer; use on tappable custom surfaces

Apply .glassEffect after layout and appearance modifiers (padding, font, foregroundStyle).

Button sizing and design handoff

Native glass buttons include ~13pt internal padding. When matching Figma or fixed-height specs:

  • Measure the outer glass bounds, not just label text size.
  • Prefer letting the button style size itself; avoid stacking extra .padding() on the label.
  • Use .buttonBorderShape(.roundedRectangle(radius:)) to match design corner radius without clipping content.
  • Avoid pre-enclosed SF Symbols (.circle, .square); the button's glass border shape already serves as the container.
Button("Continue") { next() }
    .buttonStyle(.glassProminent)
    .tint(.accentColor)
    .buttonBorderShape(.roundedRectangle(radius: 14))
    .controlSize(.large) // optional — system sizing

GlassEffectContainer spacing

GlassEffectContainer(spacing:) controls merge distance:

  • Smaller spacing — elements must be closer to visually merge.
  • Larger spacing — merge begins at greater distance (useful for toolbars that expand).
GlassEffectContainer(spacing: 40) {
    HStack(spacing: 16) {
        // glass elements
    }
}

The container spacing and inner stack spacing are independent — tune both for the desired merge behavior.

Morphing transitions

Use when glass elements appear, disappear, or move with animation:

@Namespace private var glassNS
@State private var showEraser = false

var body: some View {
    GlassEffectContainer(spacing: 32) {
        HStack(spacing: 32) {
            Image(systemName: "pencil")
                .frame(width: 64, height: 64)
                .glassEffect()
                .glassEffectID("pencil", in: glassNS)

            if showEraser {
                Image(systemName: "eraser.fill")
                    .frame(width: 64, height: 64)
                    .glassEffect()
                    .glassEffectID("eraser", in: glassNS)
            }
        }
    }

    Button("Toggle") {
        withAnimation { showEraser.toggle() }
    }
    .buttonStyle(.glass)
}

Requires @Namespace, matching glassEffectID values, and withAnimation on hierarchy changes.

Toolbar items and shared glass

On iOS 26+, items in navigation bars and window toolbars receive a shared Liquid Glass background within their logical grouping. Use .sharedBackgroundVisibility(.hidden) when an item should not show that capsule — common for plain icon buttons, custom titles, status labels, or logos.

NavigationStack {
    DetailView()
        .toolbar {
            ToolbarItem(placement: .principal) {
                BuildStatusLabel()
            }
            .sharedBackgroundVisibility(.hidden)

            ToolbarItem(placement: .topBarTrailing) {
                Button("Share", systemImage: "square.and.arrow.up") { share() }
            }
            .sharedBackgroundVisibility(.hidden)

            ToolbarItem(placement: .topBarTrailing) {
                Button("Done") { done() }
                    .buttonStyle(.glassProminent)
            }
        }
}

Notes:

  • Apply on ToolbarItem (or other ToolbarContent), not on the inner Button or label.
  • Hiding the effect places the item in its own grouping; spacing may differ from glass-backed neighbors.
  • iOS 26+ only — omit or wrap in #available(iOS 26, *) when supporting earlier OS versions.

safeAreaBar

For bottom (or top) fixed chrome with system blur:

NavigationStack {
    DetailContent()
        .safeAreaBar(.bottom) {
            HStack {
                Button("Edit") { edit() }
                    .buttonStyle(.glass)
                Spacer()
                Button("Save") { save() }
                    .buttonStyle(.glassProminent)
            }
        }
}

Prefer over:

// ❌ Manual overlay — misses system bar blur treatment
.overlay(alignment: .bottom) {
    bottomBar.background(.ultraThinMaterial)
}

// ❌ VStack pinning — fights safe area, no bar chrome
VStack {
    content
    Spacer()
    bottomBar
}

Why to avoid glass in scroll views

Scroll views continuously shift content relative to the glass sampling region. Symptoms:

  • Shimmering or unstable blur as cells move
  • Incorrect light/refraction sampling
  • Extra GPU work per frame during scroll

Alternatives for scrollable content:

  • Standard list/card backgrounds (solid, semantic, or .ultraThinMaterial on pre-26)
  • Glass only on fixed chrome: nav bars, tab bars, bottom bars via safeAreaBar, floating toolbars outside the scroll view

Pre-iOS 26 fallbacks

iOS 26+ Fallback
.glassEffect(...) .background(.ultraThinMaterial, in: shape)
.buttonStyle(.glass) .buttonStyle(.bordered)
.buttonStyle(.glassProminent) .buttonStyle(.borderedProminent)
GlassEffectContainer Plain HStack / VStack
.safeAreaBar(.bottom) .safeAreaInset(edge: .bottom) with material background
.sharedBackgroundVisibility(.hidden) Omit (no shared toolbar glass before iOS 26)

Wrap feature entry points:

@ViewBuilder
func glassSurface<Content: View>(
    @ViewBuilder content: () -> Content
) -> some View {
    if #available(iOS 26, *) {
        content().glassEffect(.regular, in: .rect(cornerRadius: 12))
    } else {
        content().background(.ultraThinMaterial, in: RoundedRectangle(cornerRadius: 12))
    }
}

Custom glass imitation — do not

These patterns look "glass-like" but are not Liquid Glass:

// ❌ All of these
.background(.ultraThinMaterial)
.background { RoundedRectangle(cornerRadius: 16).fill(.white.opacity(0.2)) }
.overlay { RoundedRectangle(cornerRadius: 16).stroke(.white.opacity(0.3)) }
.shadow(radius: 8)
.background { VisualEffectBlur() } // UIKit blur wrappers

Liquid Glass requires the system material pipeline for correct refraction, merge, and interaction. Always use .glassEffect or glass button styles.

Apple documentation

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts1mo3 checks · Risk SAFE
  • Gen Agent Trust Hub1mo

    The skill is a technical guide for using a SwiftUI 'Liquid Glass' API. It provides coding patterns, best practices, and references to official documentation. No security risks were identified.

  • Socket1mo

    No alerts

  • Snyk1mo

    Risk: LOW · No issues

Signed by skilld at 3a6c74b. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub 2 months ago.

Steadyupdated 2 months ago

README badge

README badge for flowritescode/fwc-swiftui-skills/swiftui-liquid-glass