Why need Dark Mode ?
Because it looks cool π
Correct but its not enough. Dark mode is known to save a lot of energy on AMOLED screens. ...
For further actions, you may consider blocking this person and/or reporting abuse
Nice! There is also a media query, prefers-color-scheme, that you can use to automatically detect if the user's operating system is set to dark mode!
developer.mozilla.org/en-US/docs/W...
Correct Joe, I will use that in my next article. But prefers-color-scheme not supported by many of the browsers as of now. so, I thought of going with this approach.
Nice post! But just a little tip, this expression
can be written in a bit cleaner way, if you get rid of ternary operator:
Thanks Greg, we can avoid the ternary.
But suppose a case if we didn't get theme from browser's localStorage, then it will throw undefined and assigned to isDark, but yes we can handle that later. To make the article more understandable I made it like that, so I will convey the code more clearly.
Great write up! I did the same using
class
names on<body>
for my website recently. CSS variables are really powerful.Thanks Aravind π
Amazing
Thanks Rohith
Nice one broππ
thanks π
why we dont need context api or redux here ? should we implement that ? some other examples use context api, but here it works without it, even if we have ten pages, and one button ?