aboutsummaryrefslogtreecommitdiff
path: root/layouts/partials/themeSwitcher.html
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--layouts/partials/themeSwitcher.html14
1 files changed, 14 insertions, 0 deletions
diff --git a/layouts/partials/themeSwitcher.html b/layouts/partials/themeSwitcher.html
new file mode 100644
index 0000000..685bd82
--- /dev/null
+++ b/layouts/partials/themeSwitcher.html
@@ -0,0 +1,14 @@
+<script>
+ function setTheme() {
+ const themeName = document.getElementById('themes').value;
+ localStorage.setItem('theme', themeName);
+ document.documentElement.className = themeName;
+ }
+ (function () { // Set the theme on page load
+ const themeName = localStorage.getItem('theme');
+ if (themeName) {
+ document.documentElement.className = themeName;
+ document.getElementById('themes').value = themeName;
+ }
+ })();
+</script>