Using Dark Mode in CSS with MacOS Mojave
paulmillr.com
paulmillr.com
But I don't think it's safe to assume that someone who sets a dark UI also wants web pages displayed like that.
I set dark mode in macOS to have the UI fade into the background and reveal the content; I don't want or expect that websites will present white text on a dark background too. That's fine for coding but can be less readable for long form articles depending on the ambient lighting.
I think Android has this option too?
Basically, it’s not just a “macOS thing”, lots of systems now have dark modes.
Why is that? According to [1] Safari has 14% market share. Just the desktop version has 5%.
But that is assuming the content is aimed at this group.
E.g. in a crud app with top/side nav, and then a form in the main section, the nav bars can be rendered as pale/dark to suit the user selection, while the main content area retains the focus.
Just personally don't want to read 2,000+ word articles of white text on a dark background just because I like the browser UI to be dark. Others might, though — hopefully browsers will offer a setting for dark mode independent of the OS-level setting.
To me black on white is just a hangover from old skeuomorphic design principles.
it's quite odd. It could be just a personal thing though.
The bigger factor seems to be environment you are currently in:
- Fluorescent operating room/accountant's office/Initech --> white backgrounds needed.
- Darkened lab/color-correct studio/night-time --> dark backgrounds.
And of course this has gotten worse over the years as control over the gui theme has been lost.
Just ask any Linux user that uses dark themes and you will find out what happens when the system theme messes with the site theme.
I myself always set a light theme in my Firefox config so I don't get a black on black text/background issue.
With how customized the styling on sites is every site needs to implement their own dark version otherwise you will run into situations where the styling is broken.
It is done completely different fashion than it was done on gnu/linux, on linux it was probably done by changing user agent style sheet (changes default bg color on body etc), when here it is done with media query (which webdev must explicit implement on his part so he can make sure that everything works).
Sites that support dark mode should (and will almost always) have a toggle for it. It'd be better if this setting helped _inform_ the default initial state rather than _forcing_ a choice on you. To me, that's a lot easier done with a Javascript API than CSS.
With the css solution it’s doable on a site that has no javascript.
JS should not be involved, and we don't need every site to have its own version of the switch, located in a different place and looking different.
Dark Mode should only be for UI elements not for actual content. They would never do that with a PDF either.
Hell even you-tube does that now.
I still would prefer to change a setting once, rather than establish a profile on every website to enable a dark theme.
I like to read pdfs in emacs alongside my notes, and I am very pleased that emacs' pdf-tools allows me to map colors as I choose (kind of - there are only two colors, foreground and background).
If it's done well, absolutely it's safe to assume.
I am extremely excited to research and start using this feature. I don't want to force anyone to use dark UIs that don't want them, but simultaneously I can't bring myself to make more light-themed apps and pages when I want exclusively dark themes for everything that runs on my machine.
I don't think it's safe to assume they don't. I can't stand web pages in general that are white background/black text.
I've coded in black background / white (or coloured) text for about two decades now, and I'm so glad Apple is making the dark theme a standard at this point. There's literally thousands of articles about the eye strain that's caused from the poor decision to present information this way. We don't need literally at this point millions of photons screaming light at our faces at more than 300 nits every moment.
First it was desktop with mouse -- easy. Then responsive design requiring both desktop and mobile layouts, as well as interaction design with both mouse and touch. Now what if users start expecting both light and dark versions of websites? "We show the mobile version of the menu with its own hover on small screens only, but the hover only appears if JavaScript detects a mouse, but wait we need a different hover color when it's in dark mode!"
Not to mention other standard things like making sure it works in all major browsers, or even that interactive things like comments or voting have non-JavaScript fallbacks, or that the order of elements is appropriate for screenreaders.
I love using dark mode at night, and as a user would love for every website to follow it too. But as a developer, there are just too many combinations to design and test for, and it's growing exponentially!
A quick look at Safari's desktop browser market share reveals it to be about 4% right now. When this kind of standard makes its way into Chrome and/or FF, it'll be relevant.
Until then, it's a toy, and nothing more. Nobody could ever realistically expect this kind of thing. It doesn't increase the complexity of web design by that much. If you think adding CSS exceptions for inverted colours is the straw that broke the camel's back on web complexity for you, perhaps you just feel like we should've stuck with the late 90's or worse, early 00's web standards?
Many websites, even YouTube, already have a 'night' or 'dark' switch. It makes a lot of sense, and genuinely is not that hard to implement.
It's once you try to app-ify them that things break down. Though really, with this new dark mode I just wish I could set a max whitepoint. I code in the dark but too much of the web is bright and I constantly have to change my brightness going between the two. I don't want a third party pluggin. I just want Apple to do it. The have it on the iPhone and it works great there.
Another interesting point is this might lead to yet more fingerprinting surface area. But overall, I think I'll take that over blinding myself at night.
Word processors don't have this concept, and what you see is (supposed to be) always exactly what you get. So Pages doesn't display dark documents because the output then should be a dark document.
Safari allows setting user style sheets in its Preferences: Advanced > Style sheet, so one could perhaps add a user style sheet with color-filter.
I think navigation bars (either for regular sites or functional web apps) are good candidates for honouring this setting.
If I was on a website/app though, I think I'd prefer an option provided by the site/app rather than having the OS dictate what happens.
Unfortunately it doesn't work in Chrome or Firefox yet, as they haven't implemented proper APIs.
Edit:
Ok, I've just noticed that
a) the app I have now (or maybe always?) has a couple of different levels "softer dark mode" is much nicer - it's not pure black for backgrounds.
b) using it more selectively (i.e. not just on/off for all sites) seems to work much better than just turning it on open-slather.
And for those worried about adding weight to your page just explicitly use the media query and put the over-rides in a separate file:
<link media="(prefers-color-scheme: dark)" src="..." rel="stylesheet" />
I'm not familiar with Dark Reader, but I'm guessing it's along the same lines. I've used it with Firefox Mobile for a couple months and have been happy with it.
I've been using https://addons.mozilla.org/en-US/firefox/addon/dark-night-mo... to convert webpages to darkmode.
It doesn't strictly invert, it tries to guess the color changes necessary to make the site work in darker colors.
Example of how HN looks: https://i.imgur.com/E5licCH.jpg
This will turn everything into dark mode, except images and video. And you don't have to care if site has that line in CSS. Also, when you switch back - everything is in "light mode" again, including OS UI.
FYI: Been using these extensions (or similar) for years to combat the white background fascists that took over the web and removed control of the GUI theme (in all 3 OSs!) in the last decade:
- https://addons.mozilla.org/firefox/addon/dark-background-lig...
In a darkened studio environment, one of these is a must.
I should be able to turn all of these off and make my browser indistinguishable from any other save for IP address if I so choose. This stuff just keeps rolling down the fingerprinting hill. Pretty soon they won’t need cookies at all.
Obviously there are some things that aren't yet anonymized in Safari 12, but it's good enough.
Of course, on iOS, I don’t have a choice.
I think the idea is to replace the Microsoft's proprietary -ms-high-contrast media query [2]. It means that prefers-contrast will work in Mac and Windows. Unfortunately, Safari Technology Preview 68 doesn't seem to implement it.
[1] https://drafts.csswg.org/mediaqueries-5/#prefers-contrast
$ defaults write -g NSRequiresAquaSystemAppearance -bool Yes
Logout and Choose “Dark Mode".Revert Back
$ defaults write -g NSRequiresAquaSystemAppearance -bool NoI tried to make websites look like native apps with these, haha.
Will it be possible to figure out the appearance preference with JacaScript as well?
It's a damn shame that CSS System Colors [1] was deprecated. There's also System font values [2], even if it's barely used. I really like my system styles and I wish more web services could use similar element sizes and colors. A few years back using the system font for UI elements started to gain a bit of popularity [3] [4]. WebKit even added improved support for using system fonts in web content [5], although I don't know what state that's in. I understand that exposing more system information can be used for fingerprinting, but why can't I be the one to decide what information I expose? You could expose standard color values by default and allow me to whitelist trusted websites to access real system styles.
I've thought about this a bit, and I wish websites could have different "modes" which you could switch to. I think it would make it much easier to develop and design websites that target devices with drastically different requirements. You usually want a desktop mode which is designed for use with a keyboard and mouse, and a mobile mode which is designed for use with a touch interface. The closest thing we have is the "desktop mode" switch on mobile browsers, but I think that depends on user-agent sniffing which is incredibly hacky.
I'm typically not a fan of mobile first designs, since it usually leads to a worse experience for desktop users. Using media queries with viewport size break points is usually not what you want. For example, sometimes I want to reference some API docs so I'll resize the window to be incredibly narrow and place it next to my editor. Tons of websites take this narrow screen size to mean that I'm on mobile and drastically blow up the size of the text and UI elements, causing me to lose my position in the document. This is incredibly frustrating.
Things are improving, though. Now you can use CSS media feature tests to check if the user has a pointing device [6] and if they can hover over elements [7]. Although I still think designing a website that handles all variations well is nigh impossible. Even worse, these values cannot be changed by the user! For example, imagine an advanced image editing app meant for use with a mouse. If I'm on mobile the browser could let me interface with it by providing a virtual trackpad. It might not be a great experience, but if the operation I'm doing is really simple it might be enough.
I think I'd prefer it if you could use a link tag to expose different versions of the same document, and allow the user to chose which version they prefer. Aside from providing a desktop and mobile version you could also link to an API or data view which is designed for easier consumption by computers. Another neat use for this could be to provide EPUB or PDF links for online books; you can keep reading the online version or download the full version for later.
[0] https://developer.mozilla.org/en-US/docs/Web/CSS/Alternative...
[1] https://developer.mozilla.org/en-US/docs/Web/CSS/color_value...
[2] https://developer.mozilla.org/en-US/docs/Web/CSS/font#System...
[3] https://www.smashingmagazine.com/2015/11/using-system-ui-fon...
[4] https://css-tricks.com/snippets/css/system-font-stack/
[5] https://webkit.org/blog/3709/using-the-system-font-in-web-co...
[6] https://developer.mozilla.org/en-US/docs/Web/CSS/@media/poin...
[7] https://developer.mozilla.org/en-US/docs/Web/CSS/@media/hove...
In fact, if people actually understood the first C in CSS, this thing wouldn't even be necessary.
In the color preferences, set "Override the colors specified by the page with your selections above" to "Always". By default Firefox does this automatically when the OS is in high contrast mode.