Had a great time at #IndieWebCamp Berlin this weekend.
-
Had a great time at #IndieWebCamp Berlin this weekend. Actually spent much more time thinking about dark/light mode than I thought I ever would
I believe I have understood two patterns to do that in #CSS.
@krosylight demoed their page and is using `html { color-scheme: light dark }` which then allows you to supply colors for links like `a { color: light-dark(darkblue, cyan) }`.
1/2
-
Frederik Braun �replied to Frederik Braun � last edited by
On my page, I used a different approach.
I define my colors as #CSS variables like so `:root { --color-text: #000 }` which are then changed with a media query like here
`@media (prefers-color-scheme: dark) { :root { --color-text: #fff } }`.So, should I change the variables with the media query or set them with `light-dark()` directly in the one `:root` declaration?
What would you do and why? I bet @matuzo and @Schepp have thoughts...
-
Manuel Matuzovićreplied to Frederik Braun � last edited by
-
Frederik Braun �replied to Manuel Matuzović last edited by
@matuzo @Schepp Where do you see issues with browser support in particular? MDN claims that color-scheme is widely available and light-dark() is baseline as of this year https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/light-dark. I hope my users have browsers newer than May 2024 (is that... naive?)
Oh and I also *just* found @sarajw 's article at https://css-tricks.com/come-to-the-light-dark-side/#aa-what-makes-using-color-scheme-and-light-dark-better-than-using-media-queries which points out that it makes implementing a JS based switcher easier, which is nice
-
Manuel Matuzovićreplied to Frederik Braun � last edited by
-
Frederik Braun �replied to Manuel Matuzović last edited by
-
Manuel Matuzovićreplied to Frederik Braun � last edited by