sandoche / Darkmode.js

🌓 Add a dark-mode / night-mode to your website in a few seconds
https://darkmodejs.learn.uno
MIT License
2.72k stars 176 forks source link

Starting in Dark Mode #50

Closed bryan closed 4 years ago

bryan commented 4 years ago

Is there a way to start it in dark mode via the options or to force dark mode to be the default on initial load?

sandoche commented 4 years ago
  1. You need to disable the autoMatchOsTheme to avoid to automatically activate darkmode if the browser is in darkmode.
  2. Then you need to programatically toggle darkmode using the toggle(); method

So basically you need to do something like this

const options = {
  autoMatchOsTheme: false
}

const darkmode = new Darkmode(options);
darkmode.showWidget();
darkmode.toggle();
bryan commented 4 years ago

Thanks, solution is workable.