1. CSS Kodları
PHP Kod:
:root {
--bg-color: #ffffff;
--text-color: #333333;
--button-bg: #007bff;
}
.dark-mode {
--bg-color: #181818;
--text-color: #f0f0f0;
--button-bg: #555555;
}
body {
background-color: var(--bg-color);
color: var(--text-color);
transition: 0.3s;
}
button {
background-color: var(--button-bg);
color: white;
border: none;
padding: 10px 20px;
cursor: pointer;
}
2. HTML (Buton)
PHP Kod:
<button id="theme-toggle">Mod Değiştir</button>
JavaScript Kodları
PHP Kod:
const btn = document.getElementById("theme-toggle");
const currentTheme = localStorage.getItem("theme");
if (currentTheme === "dark") {
document.body.classList.add("dark-mode");
}
btn.addEventListener("click", () => {
document.body.classList.toggle("dark-mode");
let theme = "light";
if (document.body.classList.contains("dark-mode")) {
theme = "dark";
}
localStorage.setItem("theme", theme);
});
)

