How to change color of selected buttons in SwiftUI?

I want to change foreground and background colors of selected buttons but when I click on one button it select all buttons and change their colors too. I've found solution with ID but it works with custom button ios - SwiftUI - How to change the colour of all other buttons when pressing on button? - Stack Overflow Can I change colors without creating custom button?

@State var isSelected: Bool = false
HStack {
         ForEach(category.terms, id: \.self) { attribute in
             Button {
                     print("Attr pressed")
            } label: {
                         .foregroundColor(self.isSelected ?Color.white : Color.textFieldGrayColor)
                         .background(self.isSelected ? : Color.grayButton)


If you only use a single isSelected property, what do you expect to happen? You need a separate @State property for each button.