DEV Community

Amr  khaled kilany
Amr khaled kilany

Posted on

the easiest and fastest way to make web dark mode🌟

2

demo:
https://https://app.arcade.software/share/2i5dTe1Aa0VrKHEWxn3S?

hello everyone , do you want to make dark mode in your website in seconds with high quality colors and customization you must try butterfly css its our new framework it s attribute based
how to use it

suppose you want a div be black with white text in dark mode and black text with white bg in light mode it will be:

<div dblack lwhite dtwhite tlblack></div>
Enter fullscreen mode Exit fullscreen mode

⚡dblack : bg black in dark mode
💡lwhite: white bg in light mode
🌑dtwhite : white text in dark mode
🌓tlblack :black text in light mode
how to switch
its very simple you just add the attribute 'dark-btn' to the switch button
how to customize:

use this  function in script 
  document.addEventListener("darkModeApplied", (mode) => {
    if (mode.detail.dark) {
        console.log("Dark mode is active");
        // custom dark mode logic
    } else {
        console.log("Light mode is active");
        // custom light mode logic
    }
});
Enter fullscreen mode Exit fullscreen mode

then you can use

SetAttribute('','')

and remove attribute('','')
with the attributes in our docs yu can make your dark mode in minutes not days!
cdn

 <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/AMR2010M/butterfly-css@latest/attributes.css">
<script src="https://cdn.jsdelivr.net/gh/AMR2010M/butterfly-css@latest/dark.js"></script>
Enter fullscreen mode Exit fullscreen mode

😊how to reach our website:
https://butterfly-css.netlify.app/docs
https://butterfly-css.netlify.app/
https://butterfly-css.netlify.app/blog

Top comments (0)