Bootstrap Darkmode Switch

I have tried this before without success but i googled "Bootstrap Darkmode Switch" and found this repo at the top of the list. So i thought i would give it a try on here and see how it looks. Demo page is here, lets see if it works.

The good thing about a toggle is that i can test it on every page and see what needs to be changed. I think there may be too many elements to actually change it on this site so this test might fail, but we will see. 

Download the latest release of dark mode toggle.

I have a copy here if you want to view the demo and source. 

I added the code to this page, but when toggling the dark mode switch it does not seem to apply the data attribute to the html header. I can manually add it so that proves that the css is working ok, something seems to be blocking the attribute from being added correctly. 

I think rather than digging into this one i will just mark this as a non working one for me. Here is the test of manually adding the data attribute, so that works just the script does not want to add it for me. 


<div class="custom-control custom-switch">
  <input type="checkbox" class="custom-control-input" id="darkSwitch" />
  <label class="custom-control-label" for="darkSwitch">Dark Mode</label>


[data-theme="dark"] {
  background-color: #111!important;
  color: #eee;
[data-theme="dark"] .bg-light {
    background-color: #111!important;


<link rel="stylesheet" href="/html/dark-mode-switch/dark-mode.css" />
<script src="/html/dark-mode-switch/dark-mode-switch.js"></script>

Page Views

This page has been viewed 207 times.

Search Code
Search Code by entering your search text above.

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.


Random Quote
There is a qualitative and quantitative difference between a day that begins with a little exercise, a book, meditation, a good meal, a thoughtful walk, and the start of a day that begins with a smartphone in bed.