As far as I can tell, setProperty
doesn’t seem to be working w/ CSS variables. @amandah This is something that should be updated in the docs – can you create a task for that? @pkrishna This should probably be added to our backlog to address.
In the meantime you could have a <style>
tag that you modified the text content to update the CSS variables. That seems to work, whereas setting the property directly doesn’t seem to communicate all the way through to trigger a visual update.
Getting property values back is a little more challenging – some elements should work OK if you use getComputedStyle
, but Spectrum UXP elements won’t always pass those through. For example, you could have a div
, assign the --uxp-host-text-color
value to the text color, and query it back… but this is likely asking for trouble (I think you’ll have to wait a frame before the values become stable).
In short: better to handle the colors in CSS and not use JS to read or manipulate them directly. If you need to change the value, modify the stylesheet as you would an HTML element rather than manipulating the individual rules.
All that said, it’d be good to know why you want to modify the colors via JS – what feature are you unlocking with this?