All Projects → Clashsoft → bootstrap-darkmode

Clashsoft / bootstrap-darkmode

Licence: BSD-3-Clause license
Stylesheet and scripts for implementing dark mode with Bootstrap 4

Programming Languages

HTML
75241 projects
SCSS
7915 projects
typescript
32286 projects

Projects that are alternatives of or similar to bootstrap-darkmode

mantine
React components library with native dark theme support
Stars: ✭ 4,390 (+11452.63%)
Mutual labels:  dark-theme, dark-mode
wluma
Automatic brightness adjustment based on screen contents and ALS
Stars: ✭ 290 (+663.16%)
Mutual labels:  dark-theme, dark-mode
Darkreader
Dark Reader Chrome and Firefox extension
Stars: ✭ 12,052 (+31615.79%)
Mutual labels:  dark-theme, dark-mode
dark
🌛 Dark themes / mode for Rambox, Franz or Ferdi messaging services
Stars: ✭ 93 (+144.74%)
Mutual labels:  dark-theme, dark-mode
Light-Switch
Easily switch from light to dark theme, or the other way around, in Windows 10/11.
Stars: ✭ 25 (-34.21%)
Mutual labels:  dark-theme, dark-mode
react-native-with-style
A styling package for easily adding themes to your React Native projects.
Stars: ✭ 17 (-55.26%)
Mutual labels:  dark-theme, dark-mode
charmed-dark-xcode-theme
A charming and colorful dark theme for Xcode 🌈.
Stars: ✭ 172 (+352.63%)
Mutual labels:  dark-theme, dark-mode
sketch-dark-mode
Generate a dark mode version of any Sketch document, the right way.
Stars: ✭ 58 (+52.63%)
Mutual labels:  dark-theme, dark-mode
dark-mode-example
Simple and fun dark-mode detection. JavaScript with a user mode toggle.
Stars: ✭ 27 (-28.95%)
Mutual labels:  dark-theme, dark-mode
Turn-Off-the-Lights-Firefox-extension-WebExtensions
Firefox extension (WebExtensions)
Stars: ✭ 19 (-50%)
Mutual labels:  dark-theme, dark-mode
tailwind-theme-switcher
Basic demo on how to switch styles with Tailwind, handy for dark mode type purposes.
Stars: ✭ 164 (+331.58%)
Mutual labels:  dark-theme, dark-mode
dark-mode
Dark Mode - Chrome extension. Relax your eyes at night and day.
Stars: ✭ 63 (+65.79%)
Mutual labels:  dark-theme, dark-mode
Deep-DarkFantasy
Global Dark Mode for ALL apps on ANY platforms.
Stars: ✭ 16 (-57.89%)
Mutual labels:  dark-theme, dark-mode
VS2019-Dark-Npp
Visual Studio 2019 Dark Theme for Notepad++
Stars: ✭ 146 (+284.21%)
Mutual labels:  dark-theme, dark-mode
llDark
适用于iOS深色模式的令人愉快的主题框架
Stars: ✭ 75 (+97.37%)
Mutual labels:  dark-theme, dark-mode
Halfmoon
Front-end framework with a built-in dark mode and full customizability using CSS variables; great for building dashboards and tools.
Stars: ✭ 2,583 (+6697.37%)
Mutual labels:  dark-theme, dark-mode
hash-dark-vscode
A minimal dark vscode theme inspired by Hashnode blog syntax highlighting.
Stars: ✭ 12 (-68.42%)
Mutual labels:  dark-theme, dark-mode
DarkModeSplashScreen
A sample app for iOS and Android written in Xamarin.Forms showing how to implement a Splash Page for Dark Mode
Stars: ✭ 28 (-26.32%)
Mutual labels:  dark-theme, dark-mode
Turn-Off-the-Lights-Chrome-extension
Chrome extension
Stars: ✭ 81 (+113.16%)
Mutual labels:  dark-theme, dark-mode
222
222. Dark mode. Everywhere. 222 bytes of js to make any website dark
Stars: ✭ 58 (+52.63%)
Mutual labels:  dark-theme, dark-mode

Bootstrap Darkmode

npm version

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:

$ npm install bootstrap-darkmode
$ yarn add bootstrap-darkmode
$ pnpm install bootstrap-darkmode

Include the stylesheet, e.g. in styles.scss:

@import "~bootstrap-darkmode/scss/darktheme";

Via unpkg.com

  1. Put the stylesheet link in <head>. Do not forget to add bootstrap.

    <head>
        <!-- ... -->
        <!-- Bootstrap CSS ... -->
    
        <!-- Dark mode CSS -->
        <link rel="stylesheet" href="https://unpkg.com/[email protected]/css/darktheme.css"/>
        <!-- ... -->
    </head>
  2. Load the theme script as the first thing in <body>.

    <body>
    <script src="https://unpkg.com/[email protected]/bundles/bootstrap-darkmode.umd.js"></script>
    <!-- ... --->

Building Yourself

  1. Clone this repo.
  2. Run npm build.
  3. Find darktheme.css and theme.js in the dist/ directory.
  4. 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:

import {ThemeConfig, writeDarkSwitch} from 'bootstrap-darkmode';

Browser:

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:

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:

// 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.

$dark-body-bg: #111;

@import "~bootstrap-darkmode/scss/darktheme";

JavaScript

You can listen to theme changes by registering a callback with themeChangeHandlers:

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:

themeConfig.loadTheme = () => {
    // custom logic
    return 'dark';
};

themeConfig.saveTheme = theme => {
    // custom logic
    console.log(theme);
};
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].