Jan 21, 2025

How to get Buttons in a List to work properly

If you have multiple Buttons in a SwiftUI List, you might have another button's action triggered when you tap on a button.

To fix this, add any Button style to your button, like the following. .buttonStyle(.plain) will keep the style of a standard button while fixing the issue.

List {
  HStack {
    Button("One") {
      
    }
    .buttonStyle(.plain)
    Button("Two") {
      
    }
    .buttonStyle(.plain)
  }  
}