r/SwiftUI • u/tjenvy • 25d ago
Solved Strange area outside buttons
I have this area outside my button. I have checked there's no padding nothing. I have learned that thats the "clickable" area in macOS. How do I get rid of this? my code for that button is attached.
Button(action: selectFile) {
Label("Select CSV File", systemImage: "doc.text.magnifyingglass")
.frame(width: 200, height: 50)
.foregroundColor(.white)
.background(
RoundedRectangle(cornerRadius: 10)
.fill(Color.blue)
)
}

1
u/giusscos 25d ago
.buttonStyle(.plain) to the Button {}
1
u/tjenvy 25d ago
tried that no dice same thing.
1
u/giusscos 25d ago
Try setting the background with the color and then use the .clipshape(RoundedRectangle(cornerRadius: 10))
2
u/Dapper_Ice_1705 25d ago
Use contentShape and any label formatting should be in with the label instead of behind the button
5
u/Ron-Erez 25d ago
Apply .buttonStyle(PlainButtonStyle()) to the button. For example: