You can create custom states, and when an element is clicked/selected, trigger a workflow that puts the value in the custom state. On the element, create a condition such that when the relevant custom state is not empty, then the element’s formatting changes.
When the user hits “submit”, have a workflow take the values from the various custom states and write them into the database. The last step in the workflow can set the custom state values to empty, which will cause the elements to revert to the unselected format.
If you need more help, there are some tutorials/posts on allowing users to select/deselect multiple checkboxes. The use of custom states and conditionals is similar, so it should show you the basics.
Like this one from @romanmg Bubble.io Tutorial: How to Select Multiple Items From a List - YouTube