ForEvolve / bootstrap-dark

Bootstrap 4 dark theme that supports togging dark/light themes as well. There is no fluff, it changes the color of Bootstrap and that's it, no new thing to learn or unlearn, just Bootstrap, but Dark!
MIT License
298 stars 44 forks source link
bootstrap bootstrap-4 bootstrap-dark bootstrap-theme bootstrap4 theme

Bootstrap 4 Dark theme

Bootstrap 4 dark theme that supports togging dark/light themes as well. There is no fluff, it changes the color of Bootstrap and that's it, no new thing to learn or unlearn, just Bootstrap, but Dark!

Build and deploy npm

Preview

Many controls Typography Tables Cards ListGroup Jumbotron Forms Toasts Code

Themed Dark Themed Light
Themed Dark Themed Light

Versioning

SemVer is used to keep things easy for everyone.

How to use

Official builds are available in the public npm registry.

npm install @forevolve/bootstrap-dark --save

The package contains the content of the dist directory which includes the Bootstrap JavaScript files, for convenience, and the Bootstrap Dark CSS files. To load the dark theme, <link> the bootstrap-dark.css or the bootstrap-dark.min.css instead of the bootstrap[.min].css file. You can load the bundled JavaScript files, the original ones or the file from the CDN of your choosing.

Example:

<link rel="stylesheet" href="https://github.com/ForEvolve/bootstrap-dark/blob/master/css/bootstrap-dark.min.css" />

CDN

You can also load the files using jsdelivr by following this pattern: https://cdn.jsdelivr.net/npm/@forevolve/bootstrap-dark@{NPM PACKAGE VERSION}/dist/{PATH TO THE FILE}.

Here is the preceding example using jsdelivr:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@forevolve/bootstrap-dark@1.0.0/dist/css/bootstrap-dark.min.css" />

Dark/Light toggle

You can <link> both the toggle-bootstrap.css and the toggle-bootstrap-dark.css files to allow toggling the normal/dark theme based on your page body.

If you want to support print, load the toggle-bootstrap-print.css or toggle-bootstrap-print.min.css file after the others.

Example:

<link rel="stylesheet" href="https://github.com/ForEvolve/bootstrap-dark/blob/master/css/toggle-bootstrap.min.css" />
<link rel="stylesheet" href="https://github.com/ForEvolve/bootstrap-dark/blob/master/css/toggle-bootstrap-dark.min.css" />
<link rel="stylesheet" href="https://github.com/ForEvolve/bootstrap-dark/blob/master/css/toggle-bootstrap-print.min.css" />

Using jsdelivr CDN:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@forevolve/bootstrap-dark@1.0.0/dist/css/toggle-bootstrap.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@forevolve/bootstrap-dark@1.0.0/dist/css/toggle-bootstrap-dark.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@forevolve/bootstrap-dark@1.0.0/dist/css/toggle-bootstrap-print.min.css" />

Check out the samples app for more info about this feature.

Themeable .navbar

When using the toggle-* stylesheets, you can create .navbar that uses the current theme. Light when <body class="bootstrap"> and dark when <body class="bootstrap-dark">.

Example, instead of navbar-light bg-light or navbar-dark bg-dark, use .navbar-themed, like this:

<nav class="navbar navbar-expand-lg navbar-themed">...</nav>

Check out the samples app for more info about this feature.

prefers-color-scheme

From version 1.1, I added two new css files: bootstrap-prefers-dark.css and bootstrap-prefers-light.css. Those two files use prefers-color-scheme media query instead of relying on a body's css class. There is also a new bootstrap-light.css file that is bootstrap, plus the .navbar-themed light addon.

There is two possible combination:

Here is an example for a light default:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@forevolve/bootstrap-dark@1.1.0/dist/css/bootstrap-light.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@forevolve/bootstrap-dark@1.1.0/dist/css/bootstrap-prefers-dark.min.css" />

See ./samples/html/prefers-dark-default-light.html for a working example.

Note that the print css is included in bootstrap-light.min.css.

Here is an example for a dark default:

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@forevolve/bootstrap-dark@1.1.0/dist/css/bootstrap-dark.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@forevolve/bootstrap-dark@1.1.0/dist/css/bootstrap-prefers-light.min.css" />

See ./samples/html/prefers-light-default-dark.html for a working example.

Note that the print css is included in bootstrap-dark.min.css.

bootstrap-${default}-prefers-${specific}.css

Added in version 1.2 (preview) and 2.0, the stylesheets bootstrap-dark-prefers-light.css and bootstrap-light-prefers-dark.css leverage the prefers-color-scheme CSS media query and allow a default color scheme followed by a preferred color scheme.

Technically, they are a combination of two CSS. Their high-level structure looks like the following:

/*
DEFAULT STYLES (including print styles):
bootstrap-light.css or bootstrap-dark.css
*/
@media (prefers-color-scheme: light|dark) {
    /*
    SPECIFIC COLOR STYLES:
    bootstrap-prefers-light-color-only.css or bootstrap-prefers-dark-color-only.css
    */
}

You can use these by loading one of them like this (ex.: default: light with dark support):

<link rel="stylesheet" href="https://github.com/ForEvolve/bootstrap-dark/blob/master/dist/css/bootstrap-light-prefers-dark.min.css" />

You can also use jsdelivr CDN.

<!-- Bootstrap Dark by default with `prefers: light` support -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@forevolve/bootstrap-dark@2.0.0/dist/css/bootstrap-dark-prefers-light.min.css" />
<!-- OR -->
<!-- Bootstrap (Light) by default with `prefers: dark` support -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@forevolve/bootstrap-dark@2.0.0/dist/css/bootstrap-light-prefers-dark.min.css" />

How to build

If you want to build the theme manually, modify it or even contribute, this section explains how.

Prerequisites

  1. You need npm to build this project; see Node JS for more info.
  2. You need .NET Core 3.1+; see .NET Core Downloads for more info.

    You can also test using the HTML sample, but there are more pages in the .NET app.

Getting started

  1. Clone this repo
  2. Run npm install
  3. Go to the samples/razor-pages directory (cd samples/razor-pages)
  4. Run dotnet restore

Starting the project

  1. Run dotnet run (from the samples/razor-pages directory) or if you are using VS Code, Start Debugging will work.
  2. Run npm run watch in a second terminal

Once you started both server and the watch command, the browser-sync proxy should open in a browser at the following URI: http://localhost:3000.

Other build info

There is a few npm and gulp scripts.

npm scripts

  1. gulp-watch simply runs gulp watch
  2. browser-sync-proxy starts browsersync watching for any wwwroot/css/*.css changes
  3. watch run both previous scripts in parallel

gulp scripts

  1. build-theme compile the theme to css.
  2. copy-dist-to-razor-pages copy the content of the dist folder to samples/razor-pages/wwwroot (used by the Razor Pages).
  3. copy-dist-to-html copy the content of the dist folder to samples/html (used by the HTML sample).
  4. copy-dist-to-samples executes copy-dist-to-html and copy-dist-to-razor-pages in parallel.
  5. copy-bootstrap-js copy the bootstrap js files to the dist/js directory.
  6. watch execute copy-bootstrap-js then watch to rebuild the theme.
  7. default runs copy-bootstrap-js and build-theme then copy-dist-to-samples.

The project structure

Contribute

To contribute, start by opening an issue or reply on an existing issue so we can discuss your feature or bug to find the best way to approach it.

Once we settled on a strategy, you can then Fork/Code/Open a PR.

Thanks in advance for your contribution.

See Contributing to ForEvolve open source projects and Contributor Covenant Code of Conduct for more information.

Release notes

Since CI build numbers are automated, it is hard to know in advance what the next deployed build number will be, so the (latest) version represents that version.

4.0.0

No breaking changes expected. This version only change the code/pre color. The major bump is to override the pre-release package that I deprecated recently during the no abandonned PR #63. I was not able to delete the package on NPM, so this should fix the issue.

3.0.0

2.1.1

2.1.0

2.0.0

The preview versions 1.2.x was ¾ of this. We bumped the version due to the $card-color change (see below).

Breaking changes

The $card-color variable has been reverted from $gray-200 (#e9ecef) to null (default Bootstrap value) due to a color issue in the dark/light theme.

1.1.0

1.0.0

1.0.0-alpha.1091

1.0.0-alpha.1089

1.0.0-alpha.1087

1.0.0-alpha.1075

1.0.0-alpha.978

Darken the following elements:

1.0.0-alpha.974

1.0.0-alpha.937

1.0.0-alpha.902

1.0.0-alpha.899

1.0.0-alpha.888

1.0.0-alpha.863

1.0.0-alpha.845

1.0.0-alpha.842

1.0.0-alpha.774 & 1.0.0-alpha.723

References

More darkness!

The following project applies bootstrap-dark to the bootstrap documentation site allowing deeper testing of the theme:

Special thanks

I started this project based on the Bootstrap Theme Kit by Alexander Rechsteiner at Hacker Themes. This allows me to publish a lighter version of the theme; making it easier to be used (compared to the full Bootstrap Jekyll docs).

Bootstrap 5

If you are looking for a Bootstrap 5 alternative, I suggest you look at vinorodrigues/bootstrap-dark-5. @vinorodrigues did a great job already, and whenever I have time to help, I'll do that there. I believe that we better focus on building one solid project than maintaining many. As for Boostrap 4, nothing changes about this project.