Skip to content
Discussion options

You must be logged in to vote

Here is what I did in njt (npm jump to): kachkaev/njt@1ef3bb0

  • Uses https://github.com/donavon/use-dark-mode
  • Based on setting .dark-mode / .light-mode to body. I'm using these extra class names in styled-component styles, but the trick should also work in any other styling solution
  • No initial page flickering because of a raw js injection into _document.tsx
  • Currently no on/off switch, only relying on OS values. But:
    • Adding an on/off switch should be easy, hence useDarkMode() is already used in _app.tsx
    • Changing dark mode in macOS changes the mode of the page without page reload 👀

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by SachinMaharana
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
4 participants