Tutorial membuat Dark Mode

  1. Buka akun blogger sobat.
  2. Pilih Tema.
  3. Pilih tanda panah kecil, disamping tombol "Sesuaikan".
  4. Pilih edit HTML.
  5. Tambahkan kode ini sebelum kode </head>
  6. <style>
    /* Dark Mode */
    .Switchdark{position:fixed;text-align:center;display:inline-block;align-items:center;z-index:100;right:20px;top:5px}
    .toggledarkherju{display:none;}
    .toggledarkherju-btn{display:flex;align-items:center; width:26px;height:26px;}
    .toggledarkherju-btn svg{fill:none!important;stroke:#444;stroke-linecap:round;stroke-linejoin:round;stroke-width:1}
    .toggledarkherju-btn .svg-1{display:inline-block}
    .toggledarkherju-btn .svg-2{display:none}
    .darkmode .toggledarkherju-switch:checked + .toggledarkherju-btn .svg-1{display:none}
    .darkmode .toggledarkherju-switch:checked + .toggledarkherju-btn .svg-2{display:inline-block}
    .darkmode .toggledarkherju-btn svg{stroke:#fefefe}
    .darkmode .toggledarkherju-btn .svg-1{display:none}
    .darkmode .toggledarkherju-btn .svg-2{display:inline-block}
    .darkmode .class-baru{}
    .darkmode{background:#000000;color:rgba(255,255,255,.7)}
    .darkmode a{color:rgba(255,255,255,.7)!important}
    .darkmode a:hover{color:rgba(255,255,255,.4)!important}
    .darkmode #header-blog{background:#000}
    .darkmode #footer-wrapper{background:#000}
    .darkmode #widget-title{background:#000}
    </style>
  7. Tambahkan kode ini sebelum kode </body>
  8. <div class='Switchdark'>
    <input class='toggledarkherju toggledarkherju-switch' id='darkmode' type='checkbox'/>
    <label class='toggledarkherju-btn' for='darkmode'>
    <svg class='svg-1' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'><g><path d='M183.72453,170.371a10.4306,10.4306,0,0,1-.8987,3.793,11.19849,11.19849,0,0,1-5.73738,5.72881,10.43255,10.43255,0,0,1-3.77582.89138,1.99388,1.99388,0,0,0-1.52447,3.18176,10.82936,10.82936,0,1,0,15.118-15.11819A1.99364,1.99364,0,0,0,183.72453,170.371Z' transform='translate(-169.3959 -166.45548)'/></g></svg>
    <svg class='svg-2' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'><circle cx='12' cy='12' r='5'/><line x1='12' x2='12' y1='1' y2='3'/><line x1='12' x2='12' y1='21' y2='23'/><line x1='4.22' x2='5.64' y1='4.22' y2='5.64'/><line x1='18.36' x2='19.78' y1='18.36' y2='19.78'/><line x1='1' x2='3' y1='12' y2='12'/><line x1='21' x2='23' y1='12' y2='12'/><line x1='4.22' x2='5.64' y1='19.78' y2='18.36'/><line x1='18.36' x2='19.78' y1='5.64' y2='4.22'/></svg></label>
    </div>

    <script type='text/javascript'>
    //<![CDATA[
    // Dark Mode
    document.getElementById("darkmode").addEventListener("click", function() {
    document.body.classList.toggle("darkmode");
    localStorage.setItem("toggled", document.body.classList.contains("darkmode") ? "darkmode" : "");
    });

    if (localStorage.getItem("toggled") === "darkmode") {
    document.body.classList.add("darkmode");
    }
    //]]>
    </script>
  9. Klik Simpan.
Tutorial membuat Dark Mode Tutorial membuat Dark Mode Reviewed by Herry - Juliansyah on Minggu, Maret 29, 2026 Rating: 5

Tidak ada komentar:

Daftar isi

Loading....
Diberdayakan oleh Blogger.