Home

Awesome

The Ancillary Guide to Dark Mode and Bootstrap 5

A continuation of the v4 Dark Mode POC, but this time for v5

This is a follow up to The Definitive Guide to Dark Mode and Bootstrap 4 body of work, and pertains to Bootstrap 5 (Github repo.).

If you're after the same work for Bootstrap 4 please visit the vinorodrigues/bootstrap-dark repo.


NOTE:   ⚠ An important note on status of this project ⚠:

Development efforts back at Bootstrap 5's core repository have reached v5.3 - that now includes "color modes" and within that an implementation of dark mode. See:

https://getbootstrap.com/docs/5.3/customize/color-modes/

This, thus, makes this project redundant and will be retired, leaving its code and repository here for the benefit of education.


About

This code will make little sense if you don't read The Definitive Guide to Dark Mode and Bootstrap 4 first.

What do you get?

The code compiles the four methods (and variants - six in total) of the original body of work, but compiled for and sourcing Bootstrap 5. These are:

Method 1

<small>(link to original)</small>

Method 2

<small>(link to original)</small>

Method 3

<small>(link to original)</small>

Method 4

<small>(link to original)</small>

Get started

1. bootstrap-night2. bootstrap-nightfall3. bootstrap-nightshade3b. bootstrap-blackbox4. bootstrap-dark4b. bootstrap-unlit
Quick Start GuideQuick Start GuideQuick Start GuideQuick Start GuideQuick Start GuideQuick Start Guide
darkmode.js Referencedarkmode.js Reference
See ExampleSee ExampleSee Example

The Proof is in the Pudding

Some of the test pages have been set up at vinorodrigues.github.io/bootstrap-dark-5

Can you use this?

Yes.

Licence is MIT. i.e. use as you whish as long as you credit the original authors and leave the copyright in situ.

If you're a theme builder or want to use its principles in your own project you'll need to have Git and Node installed.

  1. Fork or download the repository: git clone https://github.com/vinorodrigues/bootstrap-dark-5.git
  2. Install Node dependencies: npm install (See note below.)
  3. Modify _variables.scss and _variables-alt.scss in the scss sub-folder.
  4. Run npm run build to build your theme.
  5. The compiled code will be in the dist folder.

NOTE: The build system is based on NPM Scripts. Most of the build tools (NPM modules) will need to be installed as "global" to ensure the scripts are executable from the command line.

npm i -g  autoprefixer  documentation browser-sync  clean-css-cli  cross-env  eslint  eslint-config-xo  eslint-plugin-import  eslint-plugin-unicorn  find-unused-sass-variables  imagemin-cli  nodemon  npm-run-all  postcss-cli  rtlcss  sass  stylelint  stylelint-config-twbs-bootstrap  svgo  terser typescript

Note 1:

This code is just a rehash of Bootstrap 5 core code to add "dark mode" functionality and is declared as a "Proof of Concept" (PoC) - that means it's not intended as a production source, but merely an exercise to prove that dark-mode is attainable via various methods, i.e. it is an educative piece. It also means that it's author (Vino Rodrigues) is not compelled to support it.

Note 2:

This project will not compile with Node-Sass. Refer to the original Bootstrap 5 docs, especially here (https://getbootstrap.com/docs/5.1/getting-started/build-tools/#sass), and you'll note that they have deprecated the use of Node-Sass in favour of Dart-Sass.

They in turn cite this (https://sass-lang.com/blog/libsass-is-deprecated) article wherein the Sass curators state they will no longer support LibSass, that Node-Sass is dependant on.

NPM

Developers can include the scss and dist folders into your own project with:

npm install bootstrap-dark-5

CDN

You can also hotlink the theme via CDN with jsdelivr.com.

You can access the theme CSS file from the GitHub release:

Further Reading

Must reads for all developers wanting to write for dark mode:

Feedback

If you have useful feedback drop me an "Issue" on the GitHub Issues page.


<p align="center" style="display:block;font-size:75%;text-align:center">&copy; 2022</p>