From 287f1c6cafb5522167f3ed8d1145d6f437295f58 Mon Sep 17 00:00:00 2001 From: Phil Reid Date: Tue, 23 Jun 2026 08:28:15 +0800 Subject: [PATCH] color scheme: Use the users prefered colour scheme if one isn't defined in the store --- src/frontend/src/contexts/colorSchema.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/frontend/src/contexts/colorSchema.tsx b/src/frontend/src/contexts/colorSchema.tsx index 131e9da8e4..3eb8c94330 100644 --- a/src/frontend/src/contexts/colorSchema.tsx +++ b/src/frontend/src/contexts/colorSchema.tsx @@ -21,10 +21,16 @@ export function localStorageColorSchemeManager({ } try { - return ( - (window.localStorage.getItem(key) as MantineColorScheme) || - defaultValue - ); + const storedValue = window.localStorage.getItem(key); + + // If a value exists in storage, return it + if (storedValue && isMantineColorScheme(storedValue)) { + return storedValue; + } + + // If no value, check the system preference + const systemPrefersDark = window.matchMedia('(prefers-color-scheme: dark)').matches; + return systemPrefersDark ? 'dark' : 'light'; } catch { return defaultValue; }