How to change the property of a component from the frontend code

I am making a custom component similar to the built-in multistate button but with some extra visual. I need to determine which button has been clicked so that the onClick script will work properly. The built-in multistate button does this by changing the controlValue. I want to know how that is done so that I can implement the same behaviour.

Thanks in advance!