Hacker News new | ask | show | jobs
by muningis 1090 days ago
Your solution is more complicated, and requires JS to run. One in link, is done purely with CSS as it should be.
1 comments

No, it's not as it should be - there should always be a toggle. You should respect the user setting as the default, but please, always include a toggle.
It should not be the website's role to provide user controls over this. Having a website require JS to be acceptable is not acceptable. It's possible to use CSS only to check a input element's state, which feels like a workaround. But even then having each site provide its own way to toggle schemes in a pain. Searching for that toggle just adds to the list of settings we need to discover and configure for every notable website we visit. (Is it in the footer? Settings? User menu? Does it even exist or did I miss it?).

The browser should allow per-site toggles for prefers-color-scheme. Just like how (some?) browsers ship with page style selectors using CSS alternate tags. e.g. on Firefox Alt > View > Page Styles.

https://developer.mozilla.org/en-US/docs/Web/CSS/Alternative...

I would like proper browser toggles. But they are not here, and as long as they are not here, you should always include a toggle. Why is it not acceptable to require JS to be acceptable? You can always provide a pure CSS fallback for those who make the deliberately make the tradeoff of disabling JS. But don't force everybody else to change their whole system color preference just for your website when three lines of JS allow you to create a perfectly integrated toggle.
I think saying "everybody else" is an exaggeration. It's a minority (possibly a major on HN, including me) who tweak colour schemes. Just like how people rarely used alternate stylesheets. And why it took so long to even get "prefers-color-scheme".

Colour preferences are also not black and white, literally. There is a spectrum. Some websites' schemes are too dark or too bright. It's why sites like GitHub provide more than just two options. And why Dark Reader has sliders. In that sense, alternative stylesheets are a much better existing browser-level solution when user intervention is involved. After all, most applications provide a list of color schemes to choose from like in IDEs, terminals, word processors and so on.

The only reason I personally switch from dark to light mode on some websites is because their dark mode isn't what I want and I'd rather put up with the light mode. It's not a preference, just a compromise between two extremes.

Having an absolute stance on this is untenable since it's a complex situation depending on the site's audience, capacity, goal and so on. Let website owners decide, so they can focus on what's important to their audience.

For example, for my blog, I suggest people use the RSS feed or Reader Mode to adjust colours and font sizes to their liking. I'm not going to spend time tweaking two colour schemes for some unknown audience, which would just put me off writing and publishing.

> I think saying "everybody else" is an exaggeration. It's a minority (possibly a major on HN, including me) who tweak colour schemes.

Doesn't matter. "Everybody else" is the literal amount of people who have to change their system color scheme to change the color scheme of your website because you don't want to implement a toggle. You can't argue around that, it is per definition correct. Anyone who has JS enabled could use a toggle, but you don't implement it, so they have to change their system color scheme.

> Colour preferences are also not black and white, literally. There is a spectrum.

And because it's not black and white you force people to change their system color scheme to change your websites color scheme? This is a non-sequitur.

> The only reason I personally switch from dark to light mode on some websites is because their dark mode isn't what I want and I'd rather put up with the light mode. It's not a preference, just a compromise between two extremes.

And because of this you want to make it harder to change color schemes? How does that make any sense?

> Having an absolute stance on this is untenable since it's a complex situation depending on the site's audience, capacity, goal and so on. Let website owners decide, so they can focus on what's important to their audience.

No. Let the website owners give their users options. It's not that hard.

> For example, for my blog, I suggest people use the RSS feed or Reader Mode to adjust colours and font sizes to their liking. I'm not going to spend time tweaking two colour schemes for some unknown audience, which would just put me off writing and publishing.

And that's totally fine! If you don't have separate color schemes, it would make no sense to include a toggle. But if you have separate color schemes, add a toggle.

> No. Let the website owners give their users options. It's not that hard.

If it's not hard, shouldn't that ideal be towards the handful of browser vendors rather than the thousands/millions of website owners? I agree, if you're going out of your way to provide different stylesheets, provide a toggle, otherwise it's kind of a wasted effort anyway. However, my point of argument is the ideals. The idea someone SHOULD provide something. That SHOULD should be towards browser vendors, not website owners.

>And that's totally fine! If you don't have separate color schemes, it would make no sense to include a toggle. But if you have separate color schemes, add a toggle.

I don't think it's fine in your scenario, and the current state of things. If we require websites to individually provide their own toggles, how will the user know a toggle is even available or not? It creates an inconsistent UX where some websites have toggles and others don't. How many Hacker News visitors wasted time looking for a dark mode toggle that doesn't exist?

Which is why having it at the browser-level is necessary. Not to mention storing state, one of my pet peeves is using Incognito and losing my preferences.

It's kind of funny to me because Alternative Stylesheets solved this problem decades ago. Just like how Firefox used to have an RSS icon so we knew a website had RSS without needing to look for it. All of this stuff has been delegated to web extensions, which is barely supported on mobile. So we all need to plaster our websites with what we do and don't support and hope users find them.

It should be the user that is granted control of this regardless of the mechanism. It is more convenient for the user to have a JS toggle in the browser, but a less convenient approach can also be provided on the back end. To the back end the only difference to the HTML, which is just string data, is a single class name on a single element.