DistroHopper/website-source/toggle.html
2026-04-19 16:26:16 +02:00

14 lines
485 B
HTML

<button class="theme-toggle" onclick="toggleTheme()">🌓</button>
<script>
function toggleTheme(){
const html=document.documentElement;
const current=html.getAttribute("data-theme")||"dark";
const next=current==="dark"?"light":"dark";
html.setAttribute("data-theme",next);
localStorage.setItem("theme",next)
}
(function(){
const saved=localStorage.getItem("theme")||"dark";
document.documentElement.setAttribute("data-theme",saved)
})();
</script>