If you are a developer, you can use the following JavaScript hooks to control dark mode easily.
- To activate Dark Mode, run this method using JavaScript (works on console too): WPDarkMode.activate()
- To deactivate Dark Mode use: WPDarkMode.deactivate()
- To check if currently Dark Mode is active or not, use this getter property: WPDarkMode.isActive
- To detect the user’s system preference, run this getter property: WPDarkMode.isDeviceDark
- To prevent CSS overrides on specific elements, simply apply the following line: .wp-dark-mode-ignore
- Also, we have event listeners for dark mode, and separately for dark mode switches. If you would like to do something automated when dark mode is changed: WPDarkMode.onChange( () => { // your automated task })
Hello,
the plugin is really great, as it solves the feature of a dark mode really fast.
Nevertheless it’s kind of useless for developers, as there is no possibility to stop the plugin overwriting CSS rules. This leads to effects, where buttons are getting black in black on black background – a super no-go for UX. There should be a general CSS class, that we can use, so that the plugin will not overwrite this elements.
And no, I will not pay 180$ per site for having just a dark mode with a stopping CSS class. As a developer I don’t need all the other things around.
Best, Jan