dynamically access theme colors

Is there are way to access the theme colors from the page builder (or from javascript on runtime)?

For example, if I want to set the background of a specific wrapper component to the same value as the theme’s primary button background color, is there a way to do that so that the wrapper will dynamically get the color, even if the theme is changed?


Is there any way to dynamically access the colors of the theme?