127 comments

[ 2.7 ms ] story [ 186 ms ] thread
That's pretty awesome.
Yeah, I don't even care about dark mode, but that is very nicely done. I really like that they care enough to actually implement dark mode all the way from OS to the browser.
This is a very interesting step, considering that Apple's interface guidelines prefer that application "content" remain regularly styled (e.g. as Pages does). This seems to show that Safari's web view has been changed from being merely content to being part of the user interface, as it would in say web applications. Presumably document creation websites e.g. Google Docs would be encouraged to maintain a light-themed document while darkening the interface.

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.

However, Mail does have a dark stylesheet for the viewer when Dark Mode is enabled. I guess this can be done when there's a concept of a base stylesheet which people can the overwrite if needed.

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.

Apple is proposing a new CSS color-filter property [1], which would do the same thing as Mail does for its content. Actually, Apple is already using color-filter internally in the Mail app.

Safari allows setting user style sheets in its Preferences: Advanced > Style sheet, so one could perhaps add a user style sheet with color-filter.

[1] https://github.com/w3c/csswg-drafts/issues/2875

There are several safari extensions available already which bring dark-mode to websites. Based on the results I beleive at least some of the one I’m using must be using a filter (rather than using say manually mapped colours in a hash).
I think it's acknowledging that part of the safari window can be 'chrome'.

I think navigation bars (either for regular sites or functional web apps) are good candidates for honouring this setting.

I was reading in iBooks the other day and it changed the content to be in dark mode as well. I didn't find it jarring, but it is simply text so I was okay with it.

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.

Firefox has the option to set default colours based on your theme, so mine are set to dark colours. However, I find that many sites become unusable because they assumed the user defaults would be black text on white background. I use Stylus to override things which sometimes works but not always. Is there actually a way to fix this?
This API, presumably, once websites adopt it and actually add CSS to support darker themes.
No. This is a different thing. The problem is when people haven't coded their CSS correctly and assume default background is white and then set a non default foreground of black or something. Those sites will still break for dark themes even with this API.

In fact, if people actually understood the first C in CSS, this thing wouldn't even be necessary.

Dunno why you're being downvoted. This indeed is a very widespread problem. Even some Google services (like Google Docs) have it.
It generally happens when the site specifies the forgeround or background color but not both, leading to very low contrast.
> Is there actually a way to fix this?

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.

Dark Reader for Safari makes the web dark automatically when Dark Mode is enabled: https://darkreader.org/safari/

Unfortunately it doesn't work in Chrome or Firefox yet, as they haven't implemented proper APIs.

I tried another one of these ("Dark Mode for Safari") (https://itunes.apple.com/th/app/dark-mode-for-safari/id13971...) and was not overly impressed with the results. I guess maybe I need to be more selective about which sites it's used on.

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.

(comment deleted)
(comment deleted)
It does, go up one directory to the root on that URL. Just installed it for Chrome, am using "Dark backgrounds..." on Firefox.
He was referring to the automatically changing over option, eg: when Mojave goes Dark tell Dark Reader to also go dark.
This is a great blog post to build awareness of the prefers-color-scheme feature.

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.

https://ux.stackexchange.com/q/53264/

Would imagine they'll add the option in browsers to override the operating systems setting.
Third-party ones (Mozilla, Google) may but I'll be surprised if Apple and Microsoft don't just tie it to their respective OS' 'dark mode' setting.
Also while it's very cool that they support this in Safari, I highly doubt someone will do CSS adjustments JUST for Safari users like this. Either your page already has a dark theme or you won't really bother about this.
As someone else pointed out (https://news.ycombinator.com/item?id=18298848) this is in a draft for CSS Media Queries level 5
Hm, okay. Then it might make sense to support this, if your user base heavily relies on MacOS. Thanks for the link.
Windows has also had dark mode for apps for a while, so I wouldn't be surprised if Edge picks this up in the future.
Also on Linux GNOME has had a popular dark mode for its default theme (Adwaita) for ages now, and KDE has a bundled dark theme bundled by default (IIRC, haven’t used KDE in ages).

I think Android has this option too?

Basically, it’s not just a “macOS thing”, lots of systems now have dark modes.

If you can justify dozens of CSS adjustments for IE11, it isn't much of a stretch to spend half that amount of time making something cool for (typically) higher value Safari users as well.
What do you mean by "higher value"? Getting IE11 to work will net you an extra 2.85% of the market, but adding a very minor feature that's only usable by Safari users doesn't seem to be profitable at all.
By higher value, I mean they spend more money.
Not sure if you could back that up. I assume you say this because tech-savvy people will not use IE?

But that is assuming the content is aimed at this group.

I imagine that they’re saying Safari users are generally of a “more valuable” demographic (maybe because they’re rich enough to afford Macs?)
I'd assume this is intended for web pages/apps to allow their in-page controls/navigation to fade into the background, revealing the content.

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.

Yes, I definitely see the appeal for web apps.

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.

That’s up to website developer to make a mess of it, or to desaturate the normal color scheme or whatever other pleasant option.
I think it'll be a while before most sites even consider adopting this (it's not even listed to check support on caniuse.com), and even if it does become widespread, reader mode has style-override controls to make the page more suitable for long-form reading just as it does now.
As a counterpoint, I find a white app or webpage jarring in dark mode and much prefer light/white text on dark background. I’m happy that the rest of the os is catching up with how I’ve run my IDE for years.
I agree. It is extremely jarring to have light content in an otherwise intentionally dark-moded interface.
Well in this camp. I know there's evidence to suggest that black on white is better for reading comprehension, but I honestly find it straining.

To me black on white is just a hangover from old skeuomorphic design principles.

I found that black background with white text is great when you have perfect eyesight but once your eyesight starts to go and you start needing glasses white background with black text is easier to read.

it's quite odd. It could be just a personal thing though.

Don't believe so, have preferred dark themes and worn glasses for twenty years.

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.

it is but it's not feasible for the system theme to change the styles of websites.

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.

That I agree with, and this "responsibility" ultimately falls on the webmaster/content provider to allow a dark theme in a method similar to this post...
>it is but it's not feasible for the system theme to change the styles of websites. 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.

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).

This is why I think they should focus on exposing the dark mode setting in Javascript instead of CSS.

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.

You could easily apply or remove the css via Javascript to allow enable / disable of the feature.
Exactly. This is going to be the simplest browser extension anyone has ever written, if someone hasn’t done so already.
More javascript is almost never the best solution to any problem, particular when it’s shown that css can achieve the same result.
My argument is that CSS doesn't achieve the same result; it forces one particular mode on you instead of allowing a choice.
You have all the choice in the world. Use whatever tech you want (browser js, server side templating, client side xslt, etc) to have an attribute on the body element indicating opt-in status, and use that in your media query to target only the users who want it.

With the css solution it’s doable on a site that has no javascript.

The right place for the switch in this case is the browser. The browser should have a button for light/dark/system, defaulting to system. And CSS should follow that.

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.

You don't need Javascript to implement a switch that changes from light mode to dark mode. That can be easily done in CSS. I've done it on web sites to switch to a high-contrast color scheme for people with vision difficulties.
Exactly! That's my take on this too.

Dark Mode should only be for UI elements not for actual content. They would never do that with a PDF either.

It's really a matter of preference. I personally would be happy if my PDFs would automatically display in "dark mode" (not that I expect that to be implemented). Perhaps browsers just need a setting to toggle this.
Moon reader + on android allows you to invert the colours and that's what I do every time when I read pdf's and the like.
Ctrl+I on Evince/Atril doc viewers. Then set as default: Ctrl+T
On Linux I use MuPDF which can also invert. (Although this isn't really "dark mode", since most PDF documents are black text on white, it gets the job done.)
Curious, I ended up turning off dark mode because I found web pages were jarringly bright compared to everything else on the screen.
Don't you use websites that have a dark theme more instead. I always preferred websites that allowed me to select a dark theme and it seems to be more and more popular to do that.

Hell even you-tube does that now.

This is great, it means many sites won't have much work to support the CSS media query.

I still would prefer to change a setting once, rather than establish a profile on every website to enable a dark theme.

Well, Youtube should have had a dark theme from day one. It makes zero sense to show videos on a bright white background.
Why not? I have a chrome extension to darken and/or invert webpages and PDFs, and I have SumatraPDF setup white text on black background for editing LaTeX?
It is nice to have the option of map pdf colors to correspond to one's color 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).

I can't stare at a "light theme" screen for very long, I find.
> But I don't think it's safe to assume that someone who sets a dark UI also wants web pages displayed like that.

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.

"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 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.

As a partially sighted user this is fantastic news.
The prefers-contrast media query is even better for accessibility [1]. It allows checking if the OS is in high contrast mode and adjust the colors appropriately.

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

[2] https://msdn.microsoft.com/library/Hh771830

I’ll have to check Apple Books for this when it makes it into release WebKit. Currently we’re using :root[__ibooks_internal_theme*="Night"] to target the dark mode there (inverting black and white SVGs, etc.), but if we can use a more standardised media query that’d be a benefit.
Cmd+F5, "Invert colors" (smart invert)

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.

Is that for Safari? How long has it existed?
It's system-wide. Sorry, wrong shortcut, Alt+Cmd+F5.
By default the keyboard shortcut is disabled in Mojave, and when turned on is actually Control+Option+Command+8.
Reenable the Control-Option-Command-8 keyboard shortcut to invert colors via: System Preferences > Keyboard > Shortcuts > Accessibility > check "Invert colors".
The system dark mode is very different from invert colors.
I would be concerned about adding yet another data point that can be used for tracking.
I could see sites moving to themes that supported both light and dark - a good example of this is Arstechnica
Only if Hacker news had dark mode
Reminds me of the use of operating system colors in CSS back in the days.

I tried to make websites look like native apps with these, haha.

Those are still around, and are being used for fingerprinting devices.
Woohoo, I’ve been waiting for this.

Will it be possible to figure out the appearance preference with JacaScript as well?

Every media query can be checked using JS - `matchMedia('(prefers-color-scheme: dark)').matches` => true/false
Excellent, thanks. I see this is mentioned in the original article too; I must've missed it.
Hey Paul long time no see. Thanks for the article!
I recently heard about the Dark Reader extension for Chrome, which lets you toggle dark settings per website in a fairly intelligent way. https://chrome.google.com/webstore/detail/dark-reader/eimadp... I'm really liking it, and I'd be interested to hear about something similar for Firefox.
This is great news. And as the author mentioned suitable for “web apps” rather than something devs should add to general websites but certainly special use cases where it could make sense there too.
I, for one, am tired of web pages being able to know things about the environment in which I view them outside of their sandbox. Orientation, battery, point:pixel ratio, user-agent, referer- now UI display preferences.

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.

Canvas fingerprinting along with most of these issues were solved with Safari 12 on both Mac OS and iOS. If you don't want to be fingerprinted, consider switching to it.

Obviously there are some things that aren't yet anonymized in Safari 12, but it's good enough.

Safari’s code exec history (compared to Chrome) is enough to keep me from switching back, even if it is better at privacy in the not-execing-malicious-code typical use case.

Of course, on iOS, I don’t have a choice.

As usual Apple has set off a major change in the way we do business. Newspapers, Apps, Slack, everything is going to start supporting dark mode. I think the original way we tackled "custom color schemes" of the OS was too much - we allowed people to set individual colors for everything. Once again apple has simplified that to just light mode and dark mode. And that's how the rest of the industry will finally tackle custom color schemes (no choice but light or dark) and the OS will now dictate that setting automatically much like en-US, es-MX etc..
Sad to realize that if Slack had a real, native app, most of the conversion would be a simple toggle.
Not really. Slack would have to have a real, native app that used exclusively stock OS controls. I very much doubt they'd do that, so there would still be a lot of work required to implement dark mode.
Most Cocoa apps use system controls.
It's honestly not much dev work at all (took me a couple days on a medium size app). The real time sink is with design, because virtually any custom color you're using in the application will need a dark variant.
Actually Mac OS was always pretty restrictive in what you could customize - in some ways they've actually doubled the number of choices you now have :)
Yea and this is purely driven by Apple needs. For e.g on Apple the UI is desturated so dark mode just means go darker. But for e.g on Linux with Arc theme, dark theme has a blueish tint, so the website using dark theme will look bad on Arc theme desktop. We should at least add the option hue & saturation to light/dark setting. Then the app/website would at least fit color-wise with the theme of the OS. But only dark/light is assuming all themes are desaturated which is true for Apple but not necessarily for other platforms
For those, who like the Dark Theme on Mojave but not dark-dark everywhere.

  $ defaults write -g NSRequiresAquaSystemAppearance -bool Yes
Logout and Choose “Dark Mode".

Revert Back

  $ defaults write -g NSRequiresAquaSystemAppearance -bool No