Check out example codes for "css dark mode toggle". It will help you in understanding the concepts better.

Code Example 1

/* Answer to: "css dark mode toggle" */

/*
  Switch between dark and light mode with CSS and JavaScript using
  the tutorial you find at W3Schools, here's a link:
  Switch between dark and light mode with CSS and JavaScript.
*/

body {
  padding: 25px;
  background-color: white;
  color: black;
  font-size: 25px;
}

.dark-mode {
  background-color: black;
  color: white;
}

/*
JavaScript:
function myFunction() {
  var element = document.body;
  element.classList.toggle("dark-mode");
}
*/

Learn ReactJs, React Native from akashmittal.com