Documentation versions (currently viewingVaadin 24)

Loading Theme Images from Java Code

Images and other assets in the theme folder – except for stylesheets – can be loaded from server side code, since the frontend/themes folder is automatically copied to the resource folder as part of the build process. The path to the theme folder is “themes/theme-name/”, where theme-name is the name of the theme folder.

[project root]
└── frontend
    └── themes
        └── my-theme
            └── image.png
Image img = new Image("themes/my-theme/image.png", "An image in the theme");

Note that this does not work for stylesheets. Stylesheets need to be placed in the resource folder to be loaded dynamically from the server side. Read more about loading images on the server side.