Shared resources between themes

New user/first post…

Is ThemeResource inheritance possible? Meaning, can I create a default theme with a default /img directory, create child theme, and inherit /img dir in the child theme?

We have a default theme, but need to possibly change that theme based on the authenticated user. Most resources like icons should come from the default theme, but we want to be able to override things like MenuItem icons if necessary.

As long as your themes are both in the VAADIN directory as they should, the CSS in mytheme can refer to resources in /img e.g. with “…//img/myimage.png” - the themes share a common parent directory and both are visible to the browser.

In the docs and the forum responses there seems to be confusion between “themes” and “styles”. I am particularly interested in theme inheritance. I created a base theme with resources, and extended it. Then, I tried to access the base resources through the extended theme using ThemeResource(). It does not work.

It seems that,the section title in the Book of Vaadin, “8.3.4 Theme Inheritance”, is a misnomer. Only “style” inheritance is truly supported, especially as regards resources. Is this correct? Is there any way to achieve real theme inheritance?

Did anyone already find a solution for this problem?
We have the same problem here: different uis with different themes for different customers.
Most of the images are shared between these themes which are extended from one base-theme.
We would like to check the actual theme-image-dir and if an image can´t be found, the base-theme-image-dir should be checked.
Is there a possibility?

I was looking for the same thing but did not find a solution. Maybe the best thing is to merge the parent theme’s resources into the child theme folders as a build step, so that you can reference the resources relative to the current theme.

2018 and we still are waiting for a way to not quatriplicate resources between themes…

Hey Jose,

Can you elaborate on what you’re trying to accomplish? Accessing a theme resource via the Java API?

I achieved to use the same /icons folder for all my themes in ONE project (with vaadin 7.7.13), creating a fake theme “icons”, this is used as default when the THEME doesn’t have a specific one, since I can’t create a right inheritance between themes

/themes
   |---/icons (defaults)
   |---/theme1
   |---/theme2
	   |---/icons

I don’t know if this is right way to do it and doesn’t work always, in Vaadin 8, at compiling time it throws some errors

That structure looks correct to me. What errors are you experiencing?