At first when I heard of css variables when it was introduced, I was a bit skeptical. Why would anyone use it if there are extension languages as s...
For further actions, you may consider blocking this person and/or reporting abuse
Without CSS variables, DEV probably wouldnβt have themes, and some folks really like their dark mode π
And we thank you and the whole team for these awesome themes π€©
There's dark mode? been here since January and never noticed it πππ. just found it pretty deep in settings, would be nice to have a toggle where its better accessible.
Where can I toggle the dark mode? I can't find that option(I'm using the PWA version of DEV on my phone).
Settings -> misc -> style customization
That's dope!
I made a polyfill to target IE11
Maybe someone can use it:
github.com/nuxodin/ie11CustomPrope...
Awesome work Tobias! π
Great article, definitely learned something new here. I'm still not convinced though - how are variables transferred from one stylesheet to another? Say I scope my CSS for individual components (like in react), does it offer seamless integration like other tools already available?
If I have to edit the styles from JS whenever an event fires, why not go full blown CSS-IN-JS?
I'm afraid that I'm not the best to answer these questions, as I'm not really familiar with react and css-in-js.
But you can override css variables from another stylesheet in your own stylesheet, which could be useful.
Oh my goodness, I hadn't realized you can access these variables with JS. Thanks for sharing!
When I encountered it I had the urge to write about it π
I'm glad that this post was useful!
This is so cool!
From my point of view it's useless as long as IE11 is still used :(
It's nice to use it. But I think browser support is still an issue.
Zero IE support, for the rest it's looking good - caniuse.com/#feat=css-variables
Very nice article. Tnx Tim ... Javascript API was new to me too ...
Thanks Frederik, I'm glad you like it π
My life just changed reading this! Eye opening! I always wondered how to do themes? This answers my questions for sure! And JS API on top of it... I am blown away!
Those were exactly my thoughts Theo!
I'm glad you learned something new out of this post π
css variables are an excellent feature, but the selectbox example isn't the most useful use case IMHO... one can set those css attributes directly.
That's a great tip, thanks for sharing!
Unfortunately about 8% of the web users are still using IE11 and other browsers not supporting css vars. It depends on your company's policy if you need to take care about those users or not - we have to :(
Of course - it's good to know about "new" things but using them it's unfortunately other thing.
This fallback is good for simple cases, but if you'd like to change the value of the
--background-color
using javascript, simply changing the--background-color
variable the colors won't change it in IE.