include this script to set the bootstrap 5.3 dark-mode automatically based on system settings
Find a file
2025-01-11 21:08:41 +01:00
src auto dark mode is now only enabled, if you set the data-bs-theme to auto 2023-06-18 10:16:13 +02:00
.gitattributes initial commit 2023-06-08 17:09:24 +02:00
.gitignore initial commit 2023-06-08 17:09:24 +02:00
index.html auto dark mode is now only enabled, if you set the data-bs-theme to auto 2023-06-18 10:15:15 +02:00
LICENSE Initial commit 2023-06-08 16:44:41 +02:00
package.json 1.1.1 2025-01-11 21:08:41 +01:00
README.md README update 2025-01-11 21:08:33 +01:00

bootstrap-auto-dark-mode

This script adds the missing auto-dark mode to the new theme feature of Bootstrap 5.3.

It switches the Bootstrap theme automatically between light and dark mode, depending on the system settings, if you set the data-bs-theme attribute of your <html> to auto.

References

Usage

Use it by just including bootstrap-auto-dark-mode.js in your header and setting data-bs-theme to auto.

    <html lang="en" data-bs-theme="auto">
        <head>
            <!-- your code -->
            <script src="./src/bootstrap-auto-dark-mode.js"></script>
        </head>
        <!-- your code -->
        <!-- […] -->

Find more high quality modules from shaack.com on our projects page.