Create your own Bootstrap dark mode by changing only variables.
See the result on https://jprivet-dev.github.io/bootstrap-dark-mode/:
-
Clone the repo:
git clone https://github.com/jprivet-dev/bootstrap-dark-mode
-
Go in the project:
cd bootstrap-dark-mode
-
Install with npm:
npm install
-
Start the server:
npm run dev-server
-
Go on http://localhost:8080/
Every Sass variable in Bootstrap includes the !default
flag allowing you to override the variable’s default value
in your own Sass without modifying Bootstrap’s source code (https://getbootstrap.com/docs/4.6/getting-started/theming/#variable-defaults).
See the file on https://github.com/twbs/bootstrap/blob/v4.6.0/scss/_variables.scss.
💡
|
Sass provides the More information on https://sass-lang.com/documentation/variables#default-values. |
This project imports the precompiled Sass with Webpack Encore:
Create your own _variables.scss
and use it to override the built-in custom variables.
Then, use your main Sass file to import your custom variables, followed by Bootstrap:
@import "variables";
@import "~bootstrap/scss/bootstrap";
Yeees 🎉
If your own project is able to compile SCSS files, you can copy/past in your project all variables from the file assets/styles/_variables.scss.
Find all the colors used in assets/styles/_variables.scss.
💡
|
The colors were inspired by the different interfaces I could find on Pinterest: https://www.pinterest.fr/jeanphilipperivet/ui-dark-mode/ |
Main colors (see on coolors.co):
Shades of grey 1 (see on coolors.co):
Shades of grey 2 (see on coolors.co):
Voilà ! All you have to do is vary the colors 😃