Search code examples
gothemesfyne

How to set default theme from code using the fyne GUI framework?


I can run my Fyne application with FYNE_THEME=light to make it use a light background and running without this var it will default to dark. Is there a way to reverse this behaviour? Having the application start with the light theme by default?


Solution

  • You set the theme globally by running fyne_settings to change user theme.

    go get fyne.io/fyne/cmd/fyne_settings
    

    All fyne apps will respect the configuration set in that app.

    If your intent is to override the user theme (be careful about doing this as their settings will be ignored) you can configure the app settings in code:

    myApp.Settings().SetTheme(theme.LightTheme())