Live data from Hacker News

Dark mode in a website with CSS

tombrow.com

131–140 of 191 posts

Re: Dark mode in a website with CSS

#131

Earlier quoted context omitted.

Why mess with content colors? Just leave the images.

If you have a lot of images with white backgrounds, that's going to defeat the purpose of Dark Mode. Some people prefer dark mode because they suffer migraines and bright lights are a problem when they have a migraine. Or homeless people may be using it for both stealth purposes and battery conservation when they have limited opportunities to recharge. For some people, this preference is not just some minor detail. I…

[deleted]

Re: Dark mode in a website with CSS

#132

I love dark mode as a user, but as a developer it terrifies me how much complexity is involved in programming in 2019. At a stroke, it doubles the number of possible combinations of: - 2 device sizes: desktop vs mobile (e.g. responsive) - 3 platforms: web vs iOS vs Android, or web vs Windows vs macOS vs Linux (not even counting cross-browser or OS version quirks), or god forbid all of the above - 2 input methods: hov…

Shouldn’t the color scheme be orthogonal to input methods, platforms, and device sizes? I can’t think of any times I have changed colors specifically for any of those things.

Re: Dark mode in a website with CSS

#133

Earlier quoted context omitted.

The easy option is to just put a white background behind the diagrams. It might not be as pretty as having the image designed right for a black background but its better than that hack.

I would have thought so to but looking at the white background digrams on the dark pages was a horrible experience. It pretty much defeated the entire purpose of having a dark mode as there was these bright white diagrams shining in my eyes. Which is better you can compare Here's before dark mode https://codepen.io/greggman/full/vYYOxjd Here's leaving the backgrounds to the diagrams white https://codepen.io/greggman/…

Yeah, the hue rotation is really nice. Do you have a real example where it doesn't work?

Re: Dark mode in a website with CSS

#135

I recently added dark-mode support to a few sites. It took way more time then I thought it would. At first I thought "oh just add a few lines off CSS" but then ... * Some diagrams had white backgrounds Solution: remove the backgrounds so they are transparent * Most diagrams had black lines/arrows which didn't look good on dark gray backgrounds Solution: use CSS filter:invert for images * Some images are photos not di…

Your comment makes me glad I don't do UI's. But then I'm reminded of a syntax highlighting scheme I wish existed: You'd never define a particular color, just algorithms for taking some input color and deriving each needed color from that one. Then the user can say: "I want this file in blue and this one in orange" and the syntax highlighting still calls out the features in a relative way but the absolute colors are u…

The problem is our brains represent colour in a very weird way and the algorithms I’ve seen for this always look horrible. I guess maybe training a neural net on this might make the results more human!

Re: Dark mode in a website with CSS

#138
post #136

If you want to make sure your website is pleasant for dark-browsers, check if it doesn't break with extensions such as https://addons.mozilla.org/en-US/firefox/addon/dark-backgrou...

Or similarly for Chrome: https://chrome.google.com/webstore/detail/dark-reader/eimadp...

Re: Dark mode in a website with CSS

#139

I love dark mode as a user, but as a developer it terrifies me how much complexity is involved in programming in 2019. At a stroke, it doubles the number of possible combinations of: - 2 device sizes: desktop vs mobile (e.g. responsive) - 3 platforms: web vs iOS vs Android, or web vs Windows vs macOS vs Linux (not even counting cross-browser or OS version quirks), or god forbid all of the above - 2 input methods: hov…

The trick is to make the base as simple as possible. A static page, no items hidden behind mouse clicks or hovers. Good contrast between text and background, make sure text is resize-able. No fancy div's or nested table's for layout - so the text can flow freely and adapt to any screen size.

Only problem - that is not what the market wants. Client: "why did you not implement the scrollbar-hijack/moving-blinking-text!?!?"

Re: Dark mode in a website with CSS

#140

The problem is that this doesn't let the user toggle dark mode on/off. If you want the user to be able to toggle dark mode on your site without changing their Operating System preferences, then you'll need to implement your dark theme as a class (eg. body.theme-dark) since there's no way to dynamically set the media query. const darkMode = window.matchMedia('(prefers-color-scheme: dark)') if (darkMode) { document.bod…

Is there anything which allows user choice (i.e. state) that doesn't involve JS?

Checkbox + CSS custom properties for the colours/font weights etc . Checkbox checked, adjust the variable values.

There's normally a little more to it than that, but there shouldn't ever be _much_ more, custom properties are fully dynamic

Post reply on HN