0

Is there a possibility to change the Theme at runtime in rapidclipse? I do have user who like the dark theme where other users prefere the light theme.

As of now I just have the @Theme annotation which is setting one theme.

josef muri
  • 21
  • 2

2 Answers2

1

I could not find anything in the Vaadin Documentation regarding dynamic setting of the Theme-Variant.

But looking around I found this tutorial https://vaadin.com/learn/tutorials/toggle-dark-theme#_option_2_change_between_light_and_dark_theme_on_the_fly

By adding and removing Lumo.DARK from UI.getCurrent().getElement().getThemeList() I was able to switch between light and dark.

Downsides to this as the comments from that tutorial suggest, this seems to be more of a workaround than an actual solution. If the body tag overflows then you will see a white page where it overflows.

I hope this still helps.

Manuel Stör
  • 141
  • 1
  • 4
  • 1
    I would not call this a workaround. You can also define the theme variant in parts of the UI by setting it in specific component, or layout. – Tatu Lund Apr 16 '20 at 05:22
  • This might work in Vaadin 14 / rapdicclipse X - However I am still on Rapidclipse 4 / Vaadin 7 - where this is not applicable – josef muri Apr 16 '20 at 09:11
0

Found a solution for Vaadin 7.7.13:

    this.getUI().setTheme("MyTheme");

I have packed the code into an clicklistener of a button. "MyTheme" has to be present under WebContent/Vaadin/themes

josef muri
  • 21
  • 2