How to enable Electron to use chrome://flags/#enable-force-dark
The Electron docs specify a list of supported command line switches (some of which do come from Chromium). Unfortunately, --enable-force-dark
is not on that list.
That's because it should be:
app.commandLine.appendSwitch('enable-features', 'WebContentsForceDark');
You can find it out by enabling it and going to chrome://version
and looking at the command line.
However in this case you should use themeSource
instead.
Edit: Actually I guess that isn't the same as forcing dark mode (not sure you should do that) but if you want to I think maybe you're meant to do this instead:
new BrowserWindow({ webPreferences: { enableBlinkFeatures: "WebContentsForceDark", }, ...
I haven't tried it though, and it seems to be hella janky. I can't make it work through any method for CSSColorSchemeUARendering
.