Dark Mode Switcher For Bootstrap 4

Category: Javascript | October 13, 2020
Author: Clashsoft
Views Total: 2,300 views
Official Page: Go to website
Last Update: October 13, 2020
License: BSD 3-Clause


Dark Mode Switcher For Bootstrap 4


A tiny JavaScript & CSS implementation of the trending dark mode theme for Bootstrap 4 framework.

It saves user preference to the browser’s local storage as other dark mode plugins & scripts. jQuery and Bootstrap 4’s JS are OPTIONAL.

How to use it:

1. Load the stylesheet darktheme.css after Bootstrap’s stylesheet.

<link rel="stylesheet" href="darktheme.css" />

2. Load the core JavaScript theme.js right before the closing body tag.

<script src="theme.js"></script>

3. Load the darkswitch.js script on the webpage where you’d like to show the dark mode toggle switch. That’s it.

<script src="darkswitch.js"></script>


v0.7.0 (10/13/2020)

  • Added .bg-darkmode-black as an opposite for .bg-white.
  • Added support for data-theme=”auto”, which will automatically apply dark mode dependending on user agent preference.
  • Improved table border colors.
  • Improved horizontal rule (<hr>) color.

You Might Be Interested In:

Leave a Reply