This feature is called Dark theme. When you want the some other pages in Dark mode. To apply a dark mode we need to installe following add-ons, php and css.
All the code required for the automatic dark mode goes into the Script Organizer or functions.php file.
- Advanced Custom Fields PRO
- PHP
- CSS
Step 1) Create a custom field
Field Groups > Dark Mode for Page
- Label: Dark Mode On
- Name: dark_mode_on
- Type: True / False
Setting > Post Type is equal to Page
Presentation > Position: Side
Step 2) Added [php] Dark Theme
The function adds a class to the body definition. If the dark mode is true this function is adding .dark-mode class to the body.
Step 3) Add CSS
Style the body element that have .dark-mode class. Change the background color, text color of specific element with the class.
/* Dark mode*/
.dark-mode {
background-color: #000;
}
.dark-mode header {
background-color: #000 !important;
}
.dark-mode #main-header a:not(.elementor-sub-item) {
color: #fff !important;
}
.dark-mode .elementor-widget-theme-site-logo img {
filter: invert(1);
}
.dark-mode .elementor-nav-menu--main:not(.e--pointer-framed) .elementor-item:after {
background-color: #fff !important;
}
.dark-mode header .elementor-widget-icon svg path {
stroke: #fff !important;
}
Turn on Dark theme on the page
At the bottom, right, on the page: > Checked: Dark Mode on
Example site: https://charlescoaching.kinsta.cloud/