3 ms·
See the MDN examples: https://developer.mozilla.org/en-US/docs/Web/CSS/if https://developer.mozilla.org/en-US/docs/Web/CSS/if I for one would much rather use
by cluckindan 1y ago
See the MDN examples:
https://developer.mozilla.org/en-US/docs/Web/CSS/if https://developer.mozilla.org/en-US/docs/Web/CSS/if
I for one would much rather use local conditionals than do the logical equivalent through conditionally set CSS variables. It is much more readable and extendable than several layers of abstraction (design token vars -> semantic vars -> theme vars potentially complexed by media/container queries -> element styles).
Of course I wouldn’t replace all of that, but if() would certainly make many things easier to grok for the next guy. Just don’t overuse it.
- potato-peeler 1y agoWhat in gods abomination is this - 3px yellow if( style(--color: green): dashed; style(--color: yellow): inset; else: solid; ) —- CSS was suppose to be only for styles, single responsibility and all. What is the need to introduce logic in cascading style sheets. Isn’t js enough?
- cluckindan 1y agoDifferent responsibilities. if() seems great for multisite/multitheme enterprise applications.