Hi !
You can create a separate widget for your button, and add it dynamically to your main widget. So you can hold the logic inside, and create as many as you want.
From your main UI widget you can create and add child widget to any element like this :
If you need to differentiate your buttons, you can give them for example an “ID” variable and expose it on spawn.
Lemme know if wasn’t clear enough
Edit : sorry that’s from my project but the first node is the “create widget” node, in which you can set the class you want.
Edit 2 : If you don’t need to add the buttons via blueprint you can also do it directly in the designer : you can search your button in the ‘user created’ tab and drag and drop it into your main widget.