darkmode.js--lightweight widget to toggle darkmode plugin
This is an easy-use plugin to add darkmode to your website. I'm suprised it's basicaly depends on mix-blend-mode to modify the color sets quickly.
To make the website more customer,it's a nice try to make some difference without abundent of css code.
How to add this plugin?
With cdn related:
<script src="https://cdn.jsdelivr.net/npm/darkmode-js@1.3.4/lib/darkmode-js.min.js"></script>
<script>
new Darkmode().showWidget();
</script>
Or with npm :
npm install darkmode-js
Then add the following javascript code:
import Darkmode from 'darkmode-js';
new Darkmode().showWidget();
And Options is customized with attributes:
var options = {
bottom: '64px', // default: '32px'
right: 'unset', // default: '32px'
left: '32px', // default: 'unset'
time: '0.5s', // default: '0.3s'
mixColor: '#fff', // default: '#fff'
backgroundColor: '#fff', // default: '#fff'
buttonColorDark: '#100f2c', // default: '#100f2c'
buttonColorLight: '#fff', // default: '#fff'
saveInCookies: false, // default: true,
label: '🌓' // default: ''
}
const darkmode = new Darkmode(options);
darkmode.showWidget();
More info here