by mendelk · 10y ago · 0 comments
:root { --color: blue; }
div { --color: green; }
#alert { --color: red; }
* { color: var(--color); }
You can't accomplish that with SASS today. More info [0].In fact, this feature isn't even covered with cssnext:
The current transformation for custom properties aims to provide a future-proof way of using a limited subset (to top-level :root selector) ... [1]
I'm very curious whether or not this paradigm will be accepted as "best practice", or how it will be used.[0] https://developers.google.com/web/updates/2016/02/css-variab...
It starts with a JS API for more control over CSS Variables (which are actually called Custom Properties), and then goes into APIs for custom renders and even custom layout engines, all controlled via JS + Web Workers
Custom Properties effectively enable "styling APIs" to be declared for Custom Elements that have a shadow root, since Custom Properties cascade across shadow boundaries (detail in parent's [0]).