Dashboard Temp Share Shortlinks Frames API

HTMLify

Theme Changes
Views: 358 | Author: djdj
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Theme Switcher</title>
<style>
/* Basic Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: background 0.3s, color 0.3s;
}

/* Body Styling */
body {
    font-family: Arial, sans-serif;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Themes */
body.light {
    background: #f5f5f5;
    color: #333;
}

body.dark {
    background: #1e1e1e;
    color: #fff;
}

/* Container */
.container {
    text-align: center;
    padding: 40px;
    border-radius: 12px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    background: #fff;
    transition: transform 0.3s;
}

body.dark .container {
    background: #2c2c2c;
}

.container:hover {
    transform: scale(1.05);
}

/* Heading */
h1 {
    margin-bottom: 20px;
    font-size: 28px;
}

/* Theme Switcher */
.theme-switcher {
    display: flex;
    justify-content: center;
    gap: 20px;
}

.theme-switcher label {
    font-size: 18px;
    cursor: pointer;
}

input[type="radio"] {
    margin-right: 8px;
    cursor: pointer;
}

</style>
</head>
<body>
    <div class="container">
        <h1>Choose Your Theme</h1>
        <div class="theme-switcher">
            <label>
                <input type="radio" name="theme" value="light"> Light
            </label>
            <label>
                <input type="radio" name="theme" value="dark"> Dark
            </label>
            <label>
                <input type="radio" name="theme" value="system" checked> System
            </label>
      
        </div>
    </div>

    <script>
const applyTheme = (theme) => {
    document.body.className = theme === "system" 
        ? (window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light") 
        : theme;
    localStorage.setItem("theme", theme);
};

document.querySelectorAll('input[name="theme"]').forEach(radio => 
    radio.addEventListener("change", () => applyTheme(radio.value))
);

applyTheme(localStorage.getItem("theme") || "system");

</script>
</body>
</html>