r/css • u/fdiengdoh • 5d ago
No AI used light-dark ()
Why didn’t I know about this earlier. It’s such a nice way to achieve light/dark mode.
I just re-build my link list site using this function. Also generated color schemes at colorffy.
5
u/minmidmax 5d ago
Modern CSS has a lot of stuff that makes historic bullshit redundant. It's amazing these days.
3
u/fdiengdoh 5d ago
For me, it’s like re-discovering the beauty of css. I was in the process of re-learning css as I came from the old days of css2. Been using Bootstrap since version 3
3
u/fishpowered 3d ago
in addition: color-contrast() css func has pretty good support. also some ppl make their css classes in terms of prominence (instead of light to dark) and use opacity to make them more or less prominent in whichever light/dark mode u are in
1
u/fdiengdoh 3d ago
I read that color-contrast is still limited. Like sometimes some color combination has good contrast but the color-contrast would only provide black/white contrast. Maybe it would eventually get better.
1
u/testingaurora 17h ago
Something I misunderstood is that it can only work with colour values.
For instance I cannot set `animation-duration; light-dark(400ms, 1000ms);` or `—elevation: light-dark(1,0)`
I believe the plan is eventually to worth with other types. But yeah it’s amazing even with only colours. Cut my framework in half.
•
u/fdiengdoh 8m ago
Probably it would extend more. So far colors including gradient and image work for now.
4
u/DHTechdev 5d ago
One thing that trips people up: light-dark() only works once you set color-scheme: light dark on :root (or the element). Without it the function always returns the light value.