I'm building a website with cargo collective and I need a dark mode toggle that switch the background color on click but ever the text color. For the moment is just working with the background and it's not affecting the text.
the toggle i'm using:
**<button onclick="myFunction()">Toggle dark mode</button>
<script>
function myFunction() {
var element = document.body;
element.classList.toggle("dark-mode");
}**
</script>
Css I wrote:
body {
background-color:#d9ff76!important;
}
.dark-mode {
background-color: black!important;
}
I'd like H1 and even all the text to be affected by the dark mode but inside > .dark-mode { I can't write H1 or p or whatever.
This is how cargo define H1:
[data-predefined-style="true"] h1 {
font-family: "Le Murmure", Icons;
font-style: normal;
font-weight: 400;
padding: 0;
margin: 0;
font-size: 45rem;
line-height: 1.2;
white-space: nowrap;
}
Does anyone knows how to make it work?