https://github.com/clashsoft/bootstrap-darkmode
Stylesheet and scripts for implementing dark mode with Bootstrap 4
Science Score: 26.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
✓.zenodo.json file
Found .zenodo.json file -
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (12.6%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
Stylesheet and scripts for implementing dark mode with Bootstrap 4
Basic Info
Statistics
- Stars: 43
- Watchers: 4
- Forks: 8
- Open Issues: 0
- Releases: 18
Topics
Metadata Files
README.md
Bootstrap Darkmode
[!Warning] Bootstrap v5.3 natively provides a dark color mode. As such, this package will no longer be actively developed. Major bugs, security issues and Pull Requests will still be reviewed however. Contributions are welcome.
This project provides a stylesheet and two scripts that allow you to implement a dark theme on your website.
It is initially loaded based on user preference, can be toggled via a switch, and is saved via localStorage.
You can view the test page with all default bootstrap components in light and dark (thanks to juzraai!).
If you are using Angular, check out ng-bootstrap-darkmode.
Usage
With NPM/Yarn/PNPM
Install the npm package:
sh
$ npm install bootstrap-darkmode
$ yarn add bootstrap-darkmode
$ pnpm install bootstrap-darkmode
Include the stylesheet, e.g. in styles.scss:
scss
@import "~bootstrap-darkmode/scss/darktheme";
Via unpkg.com
Put the stylesheet link in
<head>. Do not forget to add bootstrap.```html
<!-- ... --> <!-- Bootstrap CSS ... --><!-- Dark mode CSS --> <link rel="stylesheet" href="https://unpkg.com/bootstrap-darkmode@0.7.0/css/darktheme.css"/> <!-- ... -->```
Load the theme script as the first thing in
<body>.html <body> <script src="https://unpkg.com/bootstrap-darkmode@0.7.0/bundles/bootstrap-darkmode.umd.js"></script> <!-- ... --->
Building Yourself
- Clone this repo.
- Run
npm build. - Find
darktheme.cssandtheme.jsin thedist/directory. - Follow the steps for unpkg.com, but replace the links with whatever local paths you put the files in.
Setup
If you are using ng-bootstrap-darkmode, you can skip this section entirely. It comes with its own JavaScript implementation that is used very differently.
Import
ES module import:
js
import {ThemeConfig, writeDarkSwitch} from 'bootstrap-darkmode';
Browser:
js
const bootstrapDarkmode = window['bootstrap-darkmode'];
const ThemeConfig = bootstrapDarkmode.ThemeConfig;
const writeDarkSwitch = bootstrapDarkmode.writeDarkSwitch;
Theme
As soon as possible after <body>, initialize the config and load the theme:
js
const themeConfig = new ThemeConfig();
// place customizations here
themeConfig.initTheme();
Loading the theme early shortens the time until the white default background becomes dark.
Dark Switch
If you want to use the default dark switch, load the switch script and add the element using this code:
js
// this will write the html to the document and return the element.
const darkSwitch = writeDarkSwitch(themeConfig);
Configuration
Bootstrap Darkmode can be configured regarding both colors and the way the JavaScript helper behaves.
SCSS
Many colors can be changed via SCSS variables, similar to how Bootstrap allows changing the theme.
You can find all variables in _variables.scss.
To change them, just put a new value before importing darktheme.scss.
```scss $dark-body-bg: #111;
@import "~bootstrap-darkmode/scss/darktheme"; ```
JavaScript
You can listen to theme changes by registering a callback with themeChangeHandlers:
js
config.themeChangeHandlers.push(theme => console.log(`using theme: ${theme}`));
To change the way the theme is persisted, you can change the loadTheme and saveTheme functions:
```js themeConfig.loadTheme = () => { // custom logic return 'dark'; };
themeConfig.saveTheme = theme => { // custom logic console.log(theme); }; ```
Owner
- Name: Adrian Kunz
- Login: Clashsoft
- Kind: user
- Location: Kassel, Germany
- Company: University of Kassel
- Website: https://www.clashsoft.de/
- Twitter: Clashsoft
- Repositories: 43
- Profile: https://github.com/Clashsoft
Hi there, I'm Adrian and currently a PhD Student of Computer Science.
GitHub Events
Total
Last Year
Committers
Last synced: over 1 year ago
Top Committers
| Name | Commits | |
|---|---|---|
| Adrian Kunz | c****t@h****m | 145 |
| dependabot[bot] | 4****] | 4 |
| Vít Stanislav | s****t@g****m | 1 |
Issues and Pull Requests
Last synced: 6 months ago
All Time
- Total issues: 20
- Total pull requests: 15
- Average time to close issues: 6 months
- Average time to close pull requests: 3 months
- Total issue authors: 5
- Total pull request authors: 3
- Average comments per issue: 1.55
- Average comments per pull request: 1.07
- Merged pull requests: 7
- Bot issues: 0
- Bot pull requests: 11
Past Year
- Issues: 0
- Pull requests: 1
- Average time to close issues: N/A
- Average time to close pull requests: about 1 hour
- Issue authors: 0
- Pull request authors: 1
- Average comments per issue: 0
- Average comments per pull request: 0.0
- Merged pull requests: 1
- Bot issues: 0
- Bot pull requests: 1
Top Authors
Issue Authors
- Clashsoft (16)
- virtumbe (1)
- henrikfiedler (1)
- larryathey (1)
- slaweet (1)
Pull Request Authors
- dependabot[bot] (16)
- Clashsoft (2)
- slaweet (2)
Top Labels
Issue Labels
Pull Request Labels
Packages
- Total packages: 1
-
Total downloads:
- npm 1,417 last-month
- Total dependent packages: 2
- Total dependent repositories: 28
- Total versions: 20
- Total maintainers: 1
npmjs.org: bootstrap-darkmode
Stylesheet and Scripts for implementing dark mode with Bootstrap 4
- Homepage: https://github.com/clashsoft/bootstrap-darkmode#readme
- License: BSD-3-Clause
-
Latest release: 5.0.1
published over 3 years ago
Rankings
Maintainers (1)
Dependencies
- @angular/compiler ^12.1.1 development
- @angular/compiler-cli ^12.1.1 development
- @angular/core ^12.1.1 development
- bootstrap ^4.6.0 development
- cpx ^1.5.0 development
- ng-packagr ^12.1.1 development
- sass ^1.35.2 development
- typescript ^4.3.5 development
- 504 dependencies