At the time of writing this tutorial there is no support for dark mode in electron. But it’s on its way. Before it’s released we can use Electron-packager for any electron app we want dark mode support for.
The Electron tutorial app already uses Electron packager. If your app doesn’t you can check out the electorn-packager tutorial.
However we first need to update the packager version to 12.2.0.
1. Updating to version 12.2.0 of Electron packager
open up package.json
and change:
to
and run
and to upgrade the global package use(when writing this it will give you v12.2.0):
2. Update packager script to enable dark mode
Now all we need to do is add a new option to our build script in package.json. That option is called darwinDarkModeSupport
.
currently the packager script for mac looks like this:
And when adding darwinDarkModeSupport it looks like this:
3. Package app
To see the darkmode in action we need to package the app. use
to create the package and then start the app.