mirror of
https://github.com/twbs/bootstrap.git
synced 2025-08-26 06:44:35 +02:00
Merge branch 'main' into main-lmp-contextual-theme-switcher
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/*!
|
||||
* Color mode toggler for Bootstrap's docs (https://getbootstrap.com/)
|
||||
* Copyright 2011-2023 The Bootstrap Authors
|
||||
* Copyright 2011-2024 The Bootstrap Authors
|
||||
* Licensed under the Creative Commons Attribution 3.0 Unported License.
|
||||
*/
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
}
|
||||
|
||||
const setTheme = (theme, element = document.documentElement) => {
|
||||
if (theme === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
|
||||
element.setAttribute('data-bs-theme', 'dark')
|
||||
if (theme === 'auto') {
|
||||
element.setAttribute('data-bs-theme', (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'))
|
||||
} else {
|
||||
element.setAttribute('data-bs-theme', theme)
|
||||
}
|
||||
|
Reference in New Issue
Block a user