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
- 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 })