diff --git a/src/webui/www/private/css/palette.css b/src/webui/www/private/css/palette.css
index 10fcd991b..4816be0e2 100644
--- a/src/webui/www/private/css/palette.css
+++ b/src/webui/www/private/css/palette.css
@@ -1,7 +1,7 @@
/* Adaptive color palette */
/* Default rules */
-* {
+:root {
--color-accent-blue: hsl(210deg 65% 55%);
--color-text-blue: hsl(210deg 100% 55%);
--color-text-orange: hsl(26deg 100% 45%);
@@ -16,26 +16,12 @@
--color-background-hover: hsl(26deg 80% 60%);
--color-border-blue: hsl(210deg 42% 48%);
--color-border-default: hsl(0deg 0% 85%);
-}
-:root {
- color-scheme: light dark;
-}
-
-/* Light corrections */
-@media (prefers-color-scheme: light) {
- :root {
+ &:not(.dark) {
color-scheme: light;
}
-}
-/* Dark corrections */
-@media (prefers-color-scheme: dark) {
- :root {
- color-scheme: dark;
- }
-
- * {
+ &.dark {
--color-accent-blue: hsl(210deg 42% 48%);
--color-text-blue: hsl(210deg 88.1% 73.5%);
--color-text-orange: hsl(26deg 65% 70%);
@@ -45,5 +31,7 @@
--color-background-default: hsl(0deg 0% 25%);
--color-background-hover: hsl(26deg 50% 55%);
--color-border-default: hsl(0deg 0% 33%);
+
+ color-scheme: dark;
}
}
diff --git a/src/webui/www/private/index.html b/src/webui/www/private/index.html
index 388a509fd..96a6728f3 100644
--- a/src/webui/www/private/index.html
+++ b/src/webui/www/private/index.html
@@ -1,5 +1,6 @@
-
+
+
diff --git a/src/webui/www/private/scripts/client.js b/src/webui/www/private/scripts/client.js
index 6f3f3e57a..1f140c978 100644
--- a/src/webui/www/private/scripts/client.js
+++ b/src/webui/www/private/scripts/client.js
@@ -1667,6 +1667,19 @@ window.addEventListener("load", () => {
window.qBittorrent.Cache.preferences.init();
window.qBittorrent.Cache.qbtVersion.init();
+ // Setup color scheme switching
+ const colorSchemeQuery = window.matchMedia("(prefers-color-scheme: dark)");
+ const updateColorScheme = () => {
+ const root = document.documentElement;
+ const colorScheme = LocalPreferences.get("color_scheme");
+ const validScheme = (colorScheme === "light") || (colorScheme === "dark");
+ const isDark = colorSchemeQuery.matches;
+ root.classList.toggle("dark", ((!validScheme && isDark) || (colorScheme === "dark")));
+ };
+
+ colorSchemeQuery.addEventListener("change", updateColorScheme);
+ updateColorScheme();
+
// switch to previously used tab
const previouslyUsedTab = LocalPreferences.get("selected_window_tab", "transfers");
switch (previouslyUsedTab) {
diff --git a/src/webui/www/private/views/preferences.html b/src/webui/www/private/views/preferences.html
index ffa7b2bea..6bc3567d1 100644
--- a/src/webui/www/private/views/preferences.html
+++ b/src/webui/www/private/views/preferences.html
@@ -7,6 +7,16 @@
+
+