Is there a way to access it from javaScript? Can JS code set CSS --color and make it change.
It looks like this can be changed with `setProperty`. There's a demo[1] that works on Firefox 31+ and Chrome 49+ [1] https://www.broken-links.com/2014/08/28/css-variables-updati...
CSS Variables landing in Chrome 49
51–60 of 70 posts
Re: CSS Variables landing in Chrome 49
#52Earlier quoted context omitted.
The CSS team has people like this, who no longer make websites: https://www.w3.org/People/Bos/CSS-variables Thus they're disconnected from current web developers. Meanwhile Smashing says something like 77% of audience uses SASS.
Ah, Bert Bos, the W3C's "style activity lead". What a joke. He's the guy who wasted a decade writing an ASCII-art based "template layout module"[1], which he was never able to persuade a single browser vendor to implement. It eventually got demoted from a working draft to a "note", which is the W3C's polite term for standards fanfiction. His other major achievement is putting his own photo on every one of the CSS wor…
CSS is about a decade behind where it should be, but that's not the fault of the people working on it now. And I think its future is actually comparatively bright, especially with the Houdini project taking off.
Re: CSS Variables landing in Chrome 49
#53I've wondered for years why we're using pre-processing to get variables into CSS. Given that there hasn't been a commonly advocated workflow that didn't include some sort of CSS processor (like LESS or SASS) in about a decade, it seems like somebody working on the standards would have realized that CSS needed variables, at the very least. So, it's cool that it's coming, though it's taken a lot longer than I reckon it…
The CSS team has people like this, who no longer make websites: https://www.w3.org/People/Bos/CSS-variables Thus they're disconnected from current web developers. Meanwhile Smashing says something like 77% of audience uses SASS.
Re: CSS Variables landing in Chrome 49
#54Re: CSS Variables landing in Chrome 49
#55The syntax is verbose and ugly compared to SASS
I think a lot of people agree with you but there is a reason: http://www.xanthir.com/blog/b4KT0
Re: CSS Variables landing in Chrome 49
#56Ok, that's cool. How long until we're able to use this and not have to worry about browser incompatibilities?
You can use it today with the help of http://cssnext.io
Re: CSS Variables landing in Chrome 49
#57Re: CSS Variables landing in Chrome 49
#58Just add native support for Sass and call it a day.
SASS encourage developers to build long chains of selectors and it makes them brittle and non-reusable.
The additional options for self harm are well offset by the features.
Re: CSS Variables landing in Chrome 49
#59For those commenting about SASS having this forever etc, note that this goes a step further: :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…
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
Re: CSS Variables landing in Chrome 49
#60For those commenting about SASS having this forever etc, note that this goes a step further: :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…
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]).