Loading...
Loading...
Use when implementing iOS 26 Liquid Glass effects in SwiftUI. Covers glassEffect modifier, GlassEffectContainer, morphing with glassEffectID, and correct parameter usage.
npx skill4agent add tryhuset/agent-skills ios26-liquid-glassif #available(iOS 26, *) {
content
.glassEffect()
} else {
content
.background(.ultraThinMaterial)
}.glassEffect()Text("Label")
.font(.headline) // 1. Typography
.foregroundStyle(.white) // 2. Color
.padding() // 3. Layout
.frame(width: 100) // 4. Size
.glassEffect() // 5. Glass effect lastfunc glassEffect<S: Shape>(
_ glass: Glass = .regular,
in shape: S = .capsule,
isEnabled: Bool = true
) -> some Viewstruct Glass {
static var regular: Glass // Default, medium transparency
static var clear: Glass // High transparency, for media overlays
static var identity: Glass // No effect, for conditional toggling
func tint(_ color: Color) -> Glass
func interactive() -> Glass
}| Variant | Use |
|---|---|
| Toolbars, buttons, navigation elements |
| Overlays on photos/maps/video |
| Disable effect conditionally |
// Minimal
Text("Label")
.padding()
.glassEffect()
// With parameters
Text("Label")
.padding()
.glassEffect(.regular, in: .capsule, isEnabled: true)
// Tinted
Button("Primary") { }
.glassEffect(.regular.tint(.blue))
// Interactive (adds scale, bounce, shimmer on tap)
// Only use on touch-responsive elements (buttons, controls)
Button("Tap Me") { }
.glassEffect(.regular.interactive()).regular.tint(.blue).interactive().regular.interactive().tint(.blue).glassEffect(.regular, in: .capsule) // Default
.glassEffect(.regular, in: .circle)
.glassEffect(.regular, in: .ellipse)
.glassEffect(.regular, in: RoundedRectangle(cornerRadius: 16))
.glassEffect(.regular, in: .rect(cornerRadius: .containerConcentric)).containerConcentricGlassEffectContainer {
HStack(spacing: 20) {
Button(action: {}) {
Image(systemName: "pencil")
}
.frame(width: 44, height: 44)
.glassEffect(.regular.interactive())
Button(action: {}) {
Image(systemName: "eraser")
}
.frame(width: 44, height: 44)
.glassEffect(.regular.interactive())
}
}GlassEffectContainer(spacing: 40.0) {
// elements
}GlassEffectContainerglassEffectIDfunc glassEffectID<ID: Hashable>(
_ id: ID,
in namespace: Namespace.ID
) -> some Viewstruct ExpandableToolbar: View {
@State private var isExpanded = false
@Namespace private var namespace
var body: some View {
GlassEffectContainer(spacing: 30) {
Button {
withAnimation(.bouncy) {
isExpanded.toggle()
}
} label: {
Image(systemName: isExpanded ? "xmark" : "plus")
}
.frame(width: 44, height: 44)
.glassEffect(.regular.interactive())
.glassEffectID("toggle", in: namespace)
if isExpanded {
Button { } label: {
Image(systemName: "pencil")
}
.frame(width: 44, height: 44)
.glassEffect(.regular.interactive())
.glassEffectID("pencil", in: namespace)
Button { } label: {
Image(systemName: "trash")
}
.frame(width: 44, height: 44)
.glassEffect(.regular.interactive())
.glassEffectID("trash", in: namespace)
}
}
}
}GlassEffectContainerglassEffectIDwithAnimationText("Glass Label")
.font(.title)
.bold()
.foregroundStyle(.white)
.padding()
.glassEffect()
Image(systemName: "heart.fill")
.font(.largeTitle)
.foregroundStyle(.white)
.frame(width: 60, height: 60)
.glassEffect(.regular.interactive())
Label("Settings", systemImage: "gear")
.labelStyle(.iconOnly)
.padding()
.glassEffect().interactive()GlassEffectContainer.ultraThinMaterialMenuGlassEffectContainer| Task | Code |
|---|---|
| Basic glass | |
| Tinted | |
| Interactive | |
| Custom shape | |
| Disable conditionally | |
| Group elements | |
| Enable morphing | |