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: This is a 'Work In Progress' and is specifically based on Bootstrap 5 - Beta 1 - https://github.com/twbs/bootstrap/tree/v5.0.0-beta1
NOTE: The recomendation is to not use this in a production environment.
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 only compiles the Method 1, Method 3 and Method 4 variants (for BS5) of the topics discussed in the original body of work.
i.e.:
bootstrap-night
,
bootstrap-nightshade
,
bootstrap-dark
.
The Proof Is in the Pudding
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.
- Fork or download the repository:
git clone https://github.com/vinorodrigues/bootstrap-dark-5.git
- Install Node dependencies:
npm install
(See note below.) - Modify
_variables.scss
and _variables-alt.scss
in the scss
sub-folder. - Run
npm run build
to build your theme. - 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
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:
-
bootstrap-dark
- the @media perfers-color-scheme
variant
- Production / minified variant:
- Development / Debug variant:
- Also, read the Quick Start Guide.
-
bootstrap-nightshade
- the html.body
css class + JS library variant
-
bootstrap-night
- that dark theme only variant
- Production / minified variant:
- Development / Debug variant:
- Also, read the Quick Start Guide.
-
Source etc. are here, but I recommend using GitHub.
Further Reading
Must reads for all developers wanting to write for dark mode:
-
web.dev, Thomas Steiner (@tomayac), Jun 27, 2019 (updated Jun 9, 2020), "prefers-color-scheme: Hello darkness, my old friend"
-
web.dev, Thomas Steiner (@tomayac), Apr 8, 2020 (updated Jun 16, 2020), "Improved dark mode default styling with the color-scheme CSS property and the corresponding meta tag"
-
CSS-TRICKS, Adhuham, Sep 9, 2020 "A Complete Guide to Dark Mode on the Web"
-
My bit about images and other considerations in my ".. Definitive Guide .." piece.
Feedback
If you have useful feedback drop me an "Issue" on the GitHub Issues page.
© 2021