Live data from Hacker News

Add dark mode to your website with a single line of code

github.com

1–9 of 9 posts

Re: Add dark mode to your website with a single line of code

#6
post #3

You can in fact add dark mode with a single line of code (CSS, not JS), as long as you don't change any colors: :root { color-scheme: light dark; } I don't think you need a library for that.

Not a web dev, but I saw this on a stream at some point and found it delightful. Surprisingly effective!

    html { filter: invert(100%); }

Re: Add dark mode to your website with a single line of code

#7
post #6
post #3

You can in fact add dark mode with a single line of code (CSS, not JS), as long as you don't change any colors: :root { color-scheme: light dark; } I don't think you need a library for that.

Not a web dev, but I saw this on a stream at some point and found it delightful. Surprisingly effective! html { filter: invert(100%); }

Though you probably want to apply the same filter again to non-UI images so they won't look weird.

Re: Add dark mode to your website with a single line of code

#8

> a single line of code Which means importing a whole js file

And the JS file "weights" 4 Kb.

It's fast though because it's minified and obfuscated to fit one line!!

/s haven't even looked yet, but I like hyperbole as much as the next