Dark theme as default

Hi,

Is it possible to set dark theme as default for the UI. Right now, I have to select dakr theme Everytime I login from different device or browser

Thanks

An easy way to do this is to modify the files in /www/theme/. Swap /www/theme/default/index.css and /www/theme/dark/index.css.

1 Like

Wouldn’t it be possible to select the right theme based on browser preference in future releases?

Something like the code below should help you out:

// Check to see if Media-Queries are supported
if (window.matchMedia) {
  // Check if the dark-mode Media-Query matches
  if(window.matchMedia('(prefers-color-scheme: dark)').matches){
    // Dark
  } else {
    // Light
  }
} else {
  // Default (when Media-Queries are not supported)
}

Wouldn’t this be overwritten during update?

Yes, it will, so you may need a script that executes a bit after each upgrade, for example

mv /www/theme/default/index.css /www/theme/dark/index1.css
mv /www/theme/dark/index.css /www/theme/default/index.css
mv /www/theme/dark/index1.css /www/theme/dark/index.css

Good idea, we will test it.