Skip to content

Wiggly SwiftUI Glass Buttons

FB19434107 SwiftUI Glass buttons for a Menu are shown with an odd offset/without shadow when the Menu is closed

When a glass button is used for a Menu (standalone - it works when it’s in the NavStack toolbar), when the Menu is closed, the Button is shown mis-aligned and without shadow for a little while, and snaps back to it’s correct position+shadow enabled after that.

INFO

Still happening in iOS 26.1 Beta 3.

This issue also occurs with a plain Button.

Potential workaround for glass button

swift
// » SwiftUI Garden
// » https://swiftui-garden.com/Misc/iOS-26/Wiggly-SwiftUI-Glass-Buttons

import SwiftUI

struct JumpyGlassViewExample: View {
    @State var region = Region.asia

    enum Region: String, CaseIterable {
        case asia
        case americas
    }

    var body: some View {
        NavigationStack {
            ZStack {
                Color.yellow
                    .ignoresSafeArea()
                VStack {
                    self.continentMenu
                        .border(Color.red)

                    Spacer()
                }
            }
            .navigationTitle("Example")
            .navigationBarTitleDisplayMode(.inline)
            .toolbar {
                ToolbarItem(placement: .title) {
                    self.continentMenu
                    .menuStyle(.button)
                    .buttonStyle(.glass)
                }
            }
        }
    }

    @ViewBuilder
    var continentMenu: some View {
        Menu(
            content: {
                ForEach(Region.allCases, id: \.self) { region in
                    Button(region.rawValue) {
                        self.region = region
                    }
                }
            },
            label: {
                HStack {
                    Text(region.rawValue.capitalized)
                    Image(systemName: "chevron.up.chevron.down")
                        .imageScale(.small)
                }
                .fontWeight(.semibold)
            }
        )
    }
    
}

#Preview {
    JumpyGlassViewExample()
}