Bootstrap 5 color toggle

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/

CodeFunctionName
What is this?

Public

Tested

Imported
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'

Views 179

Downloads 80

CodeID
DB ID