Working toggle button to switch between light and dark color modes in Bootstrap 5.3
I have been looking for a simple one, simplest to add to my sites, here it is.
From https://vinorodrigues.github.io/bootstrap-dark-5/
Zip file includes all you need, includes js to switch
Currently the js sets to dark mode as default (or starting color mode)
If you want to set it back to light, modify two lines in bs5-color-modes.js,
return 'dark'
//return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
to
// return 'dark'
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
Currently the js sets to dark mode as default (or starting color mode)
If you want to set it back to light, modify two lines in bs5-color-modes.js,
return 'dark'
//return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
to
// return 'dark'
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
Views 151
Downloads 67
CodeID
DB ID