0

This is what I want to achieve for the sidebar toggle button:

  • When hovering:

enter image description here

  • When not hovering:

enter image description here

This is what I have now (macOS 26):

  • When hovering:

enter image description here

  • When not hovering:

enter image description here

I want to remove the border around the button and apply my custom hovering effect, like the images of what I want to achieve above, but no matter what I do, the border of the button is still there (I asked Claude to try many different ways, but nothing works), I think that Apple baked it into the SwiftUI by default

I also tried to create the custom toolbar, but in that case, the buttons Close, Minimize, and Maximize disappear, and I have no way to bring them back.

So how to handle this?

0

1 Answer 1

1

You need .sharedBackgroundVisibility(.hidden) modifier

struct ContentView: View {
    var body: some View {
        VStack {
            Text("Main Application Content Goes Here")
                .foregroundColor(.white)
                .frame(maxWidth: .infinity, maxHeight: .infinity)
        }
        .toolbar {
            ToolbarItem(placement: .primaryAction) {
                Button("Share", systemImage: "square.and.arrow.up") {
                    
                }
            }.sharedBackgroundVisibility(.hidden) /*< That's the key */
        }
    }
}
Sign up to request clarification or add additional context in comments.

2 Comments

This is the way (only works in Mac OS 26, I guess that previous versions do not have this issue). Thanks a lot
yes, that comes together with the new glass effect modifier. Please accept the answer if it solves your problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.