DEV Community


Discussion on: Can CSS variables be watched, (need a smart cookie)

joshuajarman profile image
Joshua Jarman • Edited

Look into using MutationObserver with CSSOM:

Also worth checking out cssobj/cssobj and zeit/styled-jsx to see how a few other projects handle reactive css aspects with javascript.

also worth looking into what can be done with houdini. 🎩🐇

Reactive css is tricky, css variables are tricky, when they are evaluated, how and where they are set, in what ways and when they are static or dynamic, the cascade of full/partial inheritance/override both to and from, late unsetting, invalid value handling and falling back, the interplay of different units, etc. there are some helpful tricks like calc() wraps etc. this is all new exciting ground for css! 🎉

best of luck, it is exciting seeing these concepts being explored and pushed forward! 👍