<h2>A Simple Dark Mode Toggle Demo</h2>
  <p>Use the checkbox below to toggle between dark and light modes. This is a simple example using a moderately styled checkbox.</p>

  <input type="checkbox" id="darkToggle" class="darkToggle">
  <label for="darkToggle">

body {
  font-family: Arial, sans-serif;
  font-size: 20px;
  padding: 0 20px;

main {
  text-align: center;
  margin: 0 auto;
  max-width: 800px;

p {
  text-align: left;
  padding: 0 20px;

code {
  color: firebrick;

.darkToggle {
  appearance: none;
  width: 30px;
  height: 30px;
  background: white;
  border-radius: 5px;
  border: 2px solid #555;

.darkToggle:checked {
  background: #333;

.dark {
  color: white;
  background: #444;
let darkToggle = document.querySelector('#darkToggle');

darkToggle.addEventListener('change', ()=> {

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.