How to save a css change made dynamically with user input?

I am building an e-commerece site. And I’m using a heart font icon which acts as a tool which users can use to favorite an item in the site. So when a user clicks on the icon, it changes it color to red from black. How can I save that change in the css ?