0

I look for way in Vaadin Flow & Spring Boot to set the main theme at build time or via properties, but it is not working. Any ideas how it can be achieved?

Background: I have an application which I like to have the same code but deployed on different domains with different theme.

I tried to use a property from Spring Boot "application.properties" like "theme=my-vaadin-app", but this seems not to be supported. So any other way to set the theme at build or deploy time?

@SpringBootApplication
@Theme(value = "my-vaadin-app")  // the usual way
@Theme(vaule = "${thene}") // NOT Working
public class MyVaadinApplication  implements AppShellConfigurator {

    private static final long serialVersionUID = 1L;

    public static void main(String[] args) {
        SpringApplication.run(MyVaadinApplication  .class, args);
    }

Mark Rotteveel
  • 100,966
  • 191
  • 140
  • 197
megloff
  • 1,400
  • 4
  • 27
  • 44
  • According to this thread on vaadin forums -> [Change programmatically the Theming of the whole Application](https://vaadin.com/forum/thread/17125463/change-programmatically-the-theming-of-the-whole-application), a good starting point is using [UI.setTheme()](https://vaadin.com/download/release/8.4/8.4.3/docs/api/com/vaadin/ui/UI.html#setTheme-java.lang.String-). I think it's worth exploring. – Chaosfire Feb 17 '23 at 11:15
  • Thank you, but at which point in the startup has this to be set? – megloff Feb 17 '23 at 12:04

1 Answers1

0

The theme is included in the optimized client-side bundle that is created as part of the production build.

If there are only small differences between your different theme variants, then you can include support for all of those variants in the same theme with CSS selectors for different classnames. You can then only change the classname at runtime while always using the same CSS content.

The other alternative is that you create separate builds for separate cases.

Leif Åstrand
  • 7,820
  • 13
  • 19