Skip to content

Commit 8d5b97e

Browse files
Added mentions of non-Spring folder for stylesheets. (#5043)
* Added mentions of non-Spring folder for stylesheets. * Further clarifications on static resource folder location * Update articles/upgrading/index.adoc Co-authored-by: Marco Collovati <marco@vaadin.com> * Rephrased "compiled into WARs" as "packaged as WARs" --------- Co-authored-by: Marco Collovati <marco@vaadin.com>
1 parent 97291c8 commit 8d5b97e

File tree

4 files changed

+10
-6
lines changed

4 files changed

+10
-6
lines changed

articles/styling/advanced/dynamic-stylesheets.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ order: 40
1111

1212
Stylesheets can be loaded dynamically based on application logic on the server side. This can be useful, for example, to load styles based on the current user, or to allow the user to switch between different themes, manually.
1313

14-
This is done using the `addStyleSheet` method on the [classname]`Page` class, which takes a URL parameter. The URL can point either to a stylesheet served by the application itself, located in the resource folder `src/main/resources/META-INF/resources`, or to an external URL.
14+
This is done using the `addStyleSheet` method on the [classname]`Page` class, which takes a URL parameter. The URL can point either to a stylesheet served by the application itself, located in the resource folder `src/main/resources/META-INF/resources` (or in `src/main/webapp` for non-Spring apps packaged as WARs), or to an external URL.
1515

1616
[source,java]
1717
----

articles/styling/index.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Vaadin applications are primarily styled with CSS in style sheets, just like any
1515

1616
== Stylesheets
1717

18-
<<{articles}/styling/stylesheets#, Stylesheets>>, placed in the `src/main/resources/META-INF/resources` folder, are loaded with the [annotationname]`@StyleSheet` annotation.
18+
In most project configurations, <<{articles}/styling/stylesheets#, stylesheets>> are placed in the `src/main/resources/META-INF/resources` folder. In non-Spring projects packaged as WAR files they are placed in the `src/main/webapp` folder. In both cases they are loaded with the [annotationname]`@StyleSheet` annotation.
1919

20-
In most cases you should apply [annotationname]`@StyleSheet` annotations to the main application class that implements the [interfacename]`AppShellConfigurator` interface. This ensures that the CSS in it is applied globally, up-front, when the application UI is loaded into the browser.
20+
[annotationname]`@StyleSheet` annotations should primarily be applied to the main application class that implements the [interfacename]`AppShellConfigurator` interface. This ensures that the CSS in it is applied globally, up-front, when the application UI is loaded into the browser.
2121

2222
[source,java]
2323
----

articles/styling/stylesheets.adoc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ order: 10
99

1010
= Stylesheets
1111

12-
Stylesheets are placed in the `src/main/resources/META-INF/resources` folder, and are loaded with the [annotationname]`@StyleSheet` annotation.
12+
In most project configurations, <<{articles}/styling/stylesheets#, stylesheets>> are placed in the `src/main/resources/META-INF/resources` folder. In non-Spring projects packaged as WAR files they are placed in the `src/main/webapp` folder.
13+
14+
In both cases they are loaded with the [annotationname]`@StyleSheet` annotation.
1315

1416
In most cases you should apply [annotationname]`@StyleSheet` annotations to the main application class that implements the [interfacename]`AppShellConfigurator` interface. This ensures that the CSS in it is applied globally, up-front, when the application UI is loaded into the browser.
1517

articles/upgrading/index.adoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ The special `frontend/themes` folder, and the `components` sub-folder for CSS sh
235235

236236
Injecting CSS into Vaadin components’ shadow DOM through the `components` sub-folder in your `frontend/themes/<mytheme>` folder is disabled by default. Shadow DOM styling is no longer recommended (as of V24), but if you still need to use it, it can be enabled with the <<{articles}/flow/configuration/feature-flags#,`themeComponentStyles`>> feature flag.
237237

238-
The [annotationname]`@Theme` annotation is deprecated. Instead, the [annotationname]`@StyleSheet` annotation is now the recommended way to load Vaadin themes and custom application styles. The annotation should be placed on the application class implementing [classname]`AppShellConfigurator`:
238+
The [annotationname]`@Theme` annotation is deprecated. Instead, the [annotationname]`@StyleSheet` annotation is to be used for loading one or more <<{articles}/styling/stylesheets#,stylesheets from public static resources locations>> (e.g. `META-INF/resources/`), whereas [annotationname]`@CssImport` loads one or more stylesheets from the `src/main/frontend/` folder and use mechanisms native to HTML, CSS, and React (e.g. `@import url("morestyles.css")` in CSS).
239+
240+
The [annotationname]`@StyleSheet` annotation is now the recommended way to load Vaadin themes and styles for the application — to be placed on the application class implementing [classname]`AppShellConfigurator`. Below are some examples of how to use it:
239241

240242
[source,java]
241243
----
@@ -359,7 +361,7 @@ One exception is the `@vaadin/react-components/css/lumo/Utility.module.css` CSS
359361
These changes are optional, as old approaches still work (with the exceptions listed in the Breaking Changes section), but recommended to get your application to the new best practices in Vaadin 25, and to avoid breaking changes in later major versions.
360362

361363
* Refactor component styles from shadow DOM styles to normal CSS (this was the recommended approach already in V24). (The _Styling_ sub-pages in the component documentation provide lists of css selectors and style properties that can be used to style components this way.)
362-
* Move stylesheets from `frontend/themes/<mytheme>` to `src/main/resources/META-INF/resources`
364+
* Move stylesheets from `frontend/themes/<mytheme>` to `src/main/resources/META-INF/resources` in a Spring project, or to `src/main/webapp` in a non-Spring project.
363365
* Load custom styles through a master stylesheet with [classname]`@StyleSheet` instead of [classname]`@Theme` or multiple [classname]`@CssImport`-s
364366
* Load additional custom stylesheets through master stylesheet with `@import`
365367

0 commit comments

Comments
 (0)