home / skills / steipete / agent-scripts / swiftui-liquid-glass

swiftui-liquid-glass skill

/skills/swiftui-liquid-glass

This skill helps you implement, review, or improve SwiftUI Liquid Glass features using iOS 26+ API for cohesive, high-performance UIs.

npx playbooks add skill steipete/agent-scripts --skill swiftui-liquid-glass

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
3.7 KB
---
name: swiftui-liquid-glass
description: Implement, review, or improve SwiftUI features using the iOS 26+ Liquid Glass API. Use when asked to adopt Liquid Glass in new SwiftUI UI, refactor an existing feature to Liquid Glass, or review Liquid Glass usage for correctness, performance, and design alignment.
---

# SwiftUI Liquid Glass

_Attribution: copied from @Dimillian’s `Dimillian/Skills` (2025-12-31)._

## Overview
Use this skill to build or review SwiftUI features that fully align with the iOS 26+ Liquid Glass API. Prioritize native APIs (`glassEffect`, `GlassEffectContainer`, glass button styles) and Apple design guidance. Keep usage consistent, interactive where needed, and performance aware.

## Workflow Decision Tree
Choose the path that matches the request:

### 1) Review an existing feature
- Inspect where Liquid Glass should be used and where it should not.
- Verify correct modifier order, shape usage, and container placement.
- Check for iOS 26+ availability handling and sensible fallbacks.

### 2) Improve a feature using Liquid Glass
- Identify target components for glass treatment (surfaces, chips, buttons, cards).
- Refactor to use `GlassEffectContainer` where multiple glass elements appear.
- Introduce interactive glass only for tappable or focusable elements.

### 3) Implement a new feature using Liquid Glass
- Design the glass surfaces and interactions first (shape, prominence, grouping).
- Add glass modifiers after layout/appearance modifiers.
- Add morphing transitions only when the view hierarchy changes with animation.

## Core Guidelines
- Prefer native Liquid Glass APIs over custom blurs.
- Use `GlassEffectContainer` when multiple glass elements coexist.
- Apply `.glassEffect(...)` after layout and visual modifiers.
- Use `.interactive()` for elements that respond to touch/pointer.
- Keep shapes consistent across related elements for a cohesive look.
- Gate with `#available(iOS 26, *)` and provide a non-glass fallback.

## Review Checklist
- **Availability**: `#available(iOS 26, *)` present with fallback UI.
- **Composition**: Multiple glass views wrapped in `GlassEffectContainer`.
- **Modifier order**: `glassEffect` applied after layout/appearance modifiers.
- **Interactivity**: `interactive()` only where user interaction exists.
- **Transitions**: `glassEffectID` used with `@Namespace` for morphing.
- **Consistency**: Shapes, tinting, and spacing align across the feature.

## Implementation Checklist
- Define target elements and desired glass prominence.
- Wrap grouped glass elements in `GlassEffectContainer` and tune spacing.
- Use `.glassEffect(.regular.tint(...).interactive(), in: .rect(cornerRadius: ...))` as needed.
- Use `.buttonStyle(.glass)` / `.buttonStyle(.glassProminent)` for actions.
- Add morphing transitions with `glassEffectID` when hierarchy changes.
- Provide fallback materials and visuals for earlier iOS versions.

## Quick Snippets
Use these patterns directly and tailor shapes/tints/spacing.

```swift
if #available(iOS 26, *) {
    Text("Hello")
        .padding()
        .glassEffect(.regular.interactive(), in: .rect(cornerRadius: 16))
} else {
    Text("Hello")
        .padding()
        .background(.ultraThinMaterial, in: RoundedRectangle(cornerRadius: 16))
}
```

```swift
GlassEffectContainer(spacing: 24) {
    HStack(spacing: 24) {
        Image(systemName: "scribble.variable")
            .frame(width: 72, height: 72)
            .font(.system(size: 32))
            .glassEffect()
        Image(systemName: "eraser.fill")
            .frame(width: 72, height: 72)
            .font(.system(size: 32))
            .glassEffect()
    }
}
```

```swift
Button("Confirm") { }
    .buttonStyle(.glassProminent)
```

## Resources
- Reference guide: `references/liquid-glass.md`
- Prefer Apple docs for up-to-date API details.

Overview

This skill helps implement, refactor, or review SwiftUI features using the iOS 26+ Liquid Glass API. It focuses on native glass APIs, accessibility, and performance to deliver cohesive, interactive glass surfaces. Use it to adopt glass effects correctly across components, with sensible fallbacks for earlier iOS versions.

How this skill works

I inspect SwiftUI views for correct Liquid Glass usage: availability gating, modifier order, container composition, and interactive behavior. I refactor code to use GlassEffectContainer where many glass elements coexist, apply .glassEffect after layout modifiers, and introduce .interactive() only on tappable or focusable pieces. I also identify opportunities for morphing transitions with glassEffectID and ensure non-glass fallbacks for iOS < 26.

When to use it

  • Adding Liquid Glass to a new SwiftUI screen for iOS 26+
  • Refactoring existing UI to replace custom blur hacks with native glass APIs
  • Reviewing code for correctness, performance, and Apple design alignment
  • Designing interactive controls (buttons, chips, cards) that should feel native
  • Adding morphing transitions between related glass surfaces

Best practices

  • Prefer native .glassEffect and GlassEffectContainer over custom visual effects
  • Apply .glassEffect after layout and visual modifiers (padding, frame, background)
  • Wrap multiple adjacent glass views in GlassEffectContainer to optimize rendering and spacing
  • Use .interactive() only for elements that accept touch, pointer, or focus
  • Always gate with #available(iOS 26, *) and provide a lightweight material fallback for earlier versions
  • Keep shapes, corner radii, and tinting consistent across related components

Example use cases

  • Convert a card grid to use GlassEffectContainer and tune spacing and prominence
  • Refactor a custom blur button into .buttonStyle(.glassProminent) for consistent touch behavior
  • Add a morphing transition between a compact chip and an expanded detail view using glassEffectID and @Namespace
  • Review an app module to replace incorrect modifier order or missing availability checks
  • Implement accessible, interactive glass surfaces for settings, toolbars, and modal cards

FAQ

How do I support older iOS versions?

Gate Liquid Glass with #available(iOS 26, *) and provide a fallback using standard materials (ultraThinMaterial, regularMaterial) or a non-glass background with similar spacing and shape.

When should I use GlassEffectContainer?

Use it when multiple glass elements appear together (icons, chips, cards) to share spacing, improve rendering, and keep a cohesive effect. Individual isolated glass views don’t always need a container.