Minimal dark mode styles for Hacker News

Hacker News by 2 min read 82x views
Minimal dark mode styles for Hacker News

Share Post

For several incomprehensible reason, the Hacker News admins won't add a dreary mode. The customary workaround is to use tradition CSS alongside tools akin Stylus (Chromium, Firefox) or Userscripts (Safari, including iOS).

There are additionally multiple tradition HN web frontends, but they're frequently slow, and authentication doesn't work. You can use server-side proxying and inject the styles, but that's additional involved, and HN can rate-limit or ban server IPs. So, using tradition CSS is likely the finest choice until HN reconsiders.

There are plentifulness of dreary HN themes online, but I desire to portion the simplest one. It plant fair fine for me:

@media (prefers-color-scheme: dark) {  html {  filter: invert(1) hue-rotate(180deg);  background: #fff;  } } 

invert(1) flips all color channel: ray becomes dark, dreary becomes light, and all color turns into its complement. hue-rotate(180deg) afterward rotates the hues midway about the color wheel, about restoring the first colors. So ray and dreary are reversed, but the colors remain concerning the same. background: #fff gives the leaf a pale base, which the display changes to black.

Hacker News dreary mode

This method plant on any site, but the additional complex the first styling is, the worse the results volition be. It additionally inverts images. HN's styles are beautiful basic, so the results are fine.

While we're at it, I additionally akin to zoom the leaf on wider screens to compensate for the fixed layout and small font size:

@media (min-width: 992px) {  html {  zoom: 1.25; /* or equal 1.5 */  } } 

That's it!

★ Subscribe to keep up alongside new posts.

Other Article Hacker News
↑
Close Right Ads
Close Left Ads