@State var selection = 0 var body: some View { HStack { BackArrow() .frame(width: CGFloat(30), height: CGFloat(30)) .foregroundColor(Color(UIColor(red: 0.30, green: 0.30, blue: 0.30, alpha: 0.4))) .if(selection == 0) { $0.background(Color.white) } .if(selection != 0) { $0.background(Color.black) } .onTapGesture { withAnimation(.spring(response: 0.5)) { self.selection = 0 } } ForwardArrow() .frame(width: CGFloat(30), height: CGFloat(30)) .foregroundColor(Color(UIColor(red: 0.30, green: 0.30, blue: 0.30, alpha: 0.4))) .if(selection == 1) { $0.background(Color.white) } .if(selection != 1) { $0.background(Color.black) } .onTapGesture { withAnimation(.spring(response: 0.5)) { self.selection = 1 } } } }