Changing property (e.g. colorWidget) of a widget dynamically

I'm struggling to understand the best way to allow one widget (let's call it WidgetA) to update the color of another widget (WidgetB). There doesn't seem to be an analog of "getProp" like "setProp" so I think I'm probably trying to do something that isn't really supported?

One way I have figured out how to do this is to make WidgetB's color a variable like @{widgetBColor} and then create a variable widget to hold this value, then I can have WidgetA update widgetBColor. This works but I have a screen with dozens of buttons that need to be dynamically controlled, so I'd have to make a separate color variable for each of them.

Is there a better way to accomplish dynamic property updates?

Yes, you can write VAR{foo} in the property and call

setVar("widgetId", "foo", "red")

Brilliant! Thank you @jean-emmanuel