11 lines
333 B
JavaScript
11 lines
333 B
JavaScript
let currentTheme = localStorage.getItem("theme") || "light";
|
|
|
|
// Initialize theme
|
|
document.body.setAttribute("data-theme", currentTheme);
|
|
|
|
function toggleTheme() {
|
|
currentTheme = currentTheme === "light" ? "dark" : "light";
|
|
document.body.setAttribute("data-theme", currentTheme);
|
|
localStorage.setItem("theme", currentTheme);
|
|
}
|