Every button performs the same action because you are using the same code for every button. If you want them to do something different, you need to give them different action closures.
Generating your buttons through a ForEach isn’t a good idea if you want them all to have different actions, unless those actions are just variations on a single action. Like, if you wanted to print the button’s title or index or something like that but everything else about each button should be the same, then a ForEach would be a good way to generate them.
What are you expecting each button in your example code to do?
Thanks for the reply. I just want to add the name of the button to a text field. I want to build a paragraph based on the buttons that the user selects. There are many buttons that I might want to change over time so I put them in an array in the json file. I’m not sure if this is the best way to do it. I’m not sure how to assign the name of the button to variable in another view file.