The theme mode to set ("dark", "light", or "system")
Promise that resolves when theme is set
export async function setTheme(newTheme: ThemeMode): Promise<void> {
switch (newTheme) {
case "dark":
await window.themeMode.dark();
updateDocumentTheme(true);
break;
case "light":
await window.themeMode.light();
updateDocumentTheme(false);
break;
case "system": {
const isDarkMode = await window.themeMode.system();
updateDocumentTheme(isDarkMode);
break;
}
}
localStorage.setItem(THEME_KEY, newTheme);
}
Sets application theme to specified mode Updates both the system appearance and saves preference to localStorage