mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Use light/dark theme based on system preference (#17051)
Add a new default theme `auto`, which will automatically switch between `gitea` (light) and `arc-green` (dark) themes depending on the user's operating system settings. Closes: #8183
This commit is contained in:
		@@ -26,7 +26,13 @@ export function isObject(obj) {
 | 
			
		||||
 | 
			
		||||
// returns whether a dark theme is enabled
 | 
			
		||||
export function isDarkTheme() {
 | 
			
		||||
  return document.documentElement.classList.contains('theme-arc-green');
 | 
			
		||||
  if (document.documentElement.classList.contains('theme-auto')) {
 | 
			
		||||
    return window.matchMedia('(prefers-color-scheme: dark)').matches;
 | 
			
		||||
  }
 | 
			
		||||
  if (document.documentElement.classList.contains('theme-arc-green')) {
 | 
			
		||||
    return true;
 | 
			
		||||
  }
 | 
			
		||||
  return false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// removes duplicate elements in an array
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user