Skip to content

Commit 2f159f8

Browse files
committed
theme docs update
1 parent 5087d4b commit 2f159f8

23 files changed

+648
-222
lines changed
-138 KB
Loading
-105 KB
Loading
-48.3 KB
Loading

articles/styling/index.adoc

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,24 @@ public class Application implements AppShellConfigurator {
2929

3030
You can split your CSS over multiple stylesheets, and load them either with separate [annotationname]`@StyleSheet` annotations, or load additional stylesheets using the CSS `@import` rule.
3131

32-
.src/main/resources/META-INF/resources/styles.css
32+
.`src/main/resources/META-INF/resources/styles.css`
3333
[source,css]
3434
----
3535
@import "additional-styles.css";
3636
3737
/* your CSS goes here */
3838
----
3939

40-
More details are provided in the <<{articles}/styling/stylesheets#, Stylesheets>> section.
40+
You can find more details in the <<{articles}/styling/stylesheets#, Stylesheets>> section.
4141

42-
.Vaadin 24 way of applying styles is deprecated but supported
42+
.@Theme is deprecated but supported.
4343
[NOTE]
44-
The Vaadin 24 way of loading styles through the [annotationname]`@Theme` annotation and a theme folder in `frontend/themes` has been deprecated in Vaadin 25, but is still supported through the `themeComponentStyles` <<{articles}/flow/configuration/feature-flags#,feature flag>>. Please see the link:/docs/v24/styling[Vaadin 24 Styling documentation] for details on this usage.
44+
Loading styles through the [annotationname]`@Theme` annotation and a theme folder in `frontend/themes` has been deprecated, but is still supported through the `themeComponentStyles` <<{articles}/flow/configuration/feature-flags#,feature flag>>. See the link:/docs/v24/styling[Vaadin 24 Styling documentation] for details on this usage.
4545

4646

4747
== Themes
4848

49-
By default, Vaadin components are rendered with their minimalistic built-in <<themes/base#, base styles>>, which are a good starting point if you want to customize the look and feel extensively. Vaadin also ships with two themes, <<themes/aura#, Aura>> and <<themes/lumo#, Lumo>>, that provide a more polished look and feel for Vaadin components.
49+
By default, Vaadin components are rendered with their simple built-in <<themes/base#, base styles>>, which are a good starting point if you want to customize the look and feel extensively. Vaadin also ships with two themes, <<themes/aura#, Aura>> and <<themes/lumo#, Lumo>>, that give a more polished look and feel for Vaadin components.
5050

5151
[cols="^.^1, ^.^1, ^.^1"]
5252
|===
@@ -59,9 +59,9 @@ By default, Vaadin components are rendered with their minimalistic built-in <<th
5959
|image:_images/lumo-theme.png[Login form using the Lumo theme, width=100%]
6060
|===
6161

62-
Vaadin themes can be loaded with the [annotationname]`@StyleSheet` annotation. The [classname]`Aura` and [classname]`Lumo` Java classes provide constants for the stylesheet path that can be used with the [annotationname]`@StyleSheet` annotation.
62+
Vaadin themes can be loaded with the [annotationname]`@StyleSheet` annotation. The [classname]`Aura` and [classname]`Lumo` Java classes have constants for the stylesheet path that can be used with the [annotationname]`@StyleSheet` annotation.
6363

64-
Note that themes should be imported before any other styles in your application.
64+
Themes should be imported before any other styles in your application, so that style customizations have a higher specificity.
6565

6666
[source,java]
6767
----
@@ -73,7 +73,7 @@ public class Application implements AppShellConfigurator {
7373
}
7474
----
7575

76-
Both themes provide a comprehensive set of style properties (CSS custom properties) that make them easily customizable without complex CSS selectors. These properties are listed on the <<themes/aura#, Aura>> and <<themes/lumo#, Lumo>> reference pages.
76+
Both themes offer a comprehensive set of style properties (CSS custom properties) that make them customizable without complex CSS selectors. These properties are listed on the <<themes/aura#, Aura>> and <<themes/lumo#, Lumo>> reference pages.
7777

7878
[source,css]
7979
----
@@ -88,7 +88,7 @@ You can choose to apply your own styling on top of either theme, or on top of th
8888

8989
== Component Style Properties
9090

91-
Vaadin components also provide their own component-specific style properties for customizing their styles. These properties are listed on the Styling sub-pages in the component documentation (see e.g. <<{articles}/components/text-field/styling#,Text Field>>), along with the most common CSS selectors you can use to target the parts and states of components with your own CSS.
91+
Vaadin components also have their own component-specific style properties for customizing their styles. These properties are listed on the Styling sub-pages in the component documentation (e.g., <<{articles}/components/text-field/styling#,Text Field Styling>>), along with the most common CSS selectors you can use to target the parts and states of components with your own CSS.
9292

9393
Component style properties differ from theme style properties in that they are specific to a particular component type.
9494

@@ -103,7 +103,7 @@ html {
103103

104104
== Applying CSS to Components
105105

106-
The most common selectors needed to style Vaadin components are listed on the _Styling_ sub-pages in the component documentation (see e.g. <<{articles}/components/text-field/styling#,Text Field>>), along with the style properties built into the components.
106+
The most common selectors needed to style Vaadin components are listed on the _Styling_ sub-pages in the component documentation (e.g., <<{articles}/components/text-field/styling#,Text Field Styling>>), along with the style properties built into the components.
107107

108108
.Applying custom CSS to a component's state and part
109109
[source,css]
@@ -116,20 +116,21 @@ vaadin-button[disabled]::part(label) {
116116

117117
== Component Style Variants
118118

119-
Many Vaadin components also have style variants as built-in features. These can be found in the documentation for each component.
119+
Many Vaadin components also have style variants as a built-in feature. You can find supported variants in the documentation for each component.
120120

121121
.Button component variants in Aura theme
122-
image::_images/component-variants.png[width=50%]
122+
[.fill.white]
123+
image::_images/component-variants.png[width=612]
123124

124125

125126
== Recommended Approach
126127

127128
The recommended approach to styling Vaadin components is:
128129

129130
* *Theme*: choose the <<{articles}/styling/themes#,theme>> that is the best match to your desired look and feel for components, or stick to the components’ base styles if neither theme is a good match;
130-
* *Variant*: check if the component provides a style variant that corresponds (at least partially) to what youre after;
131+
* *Variant*: check if the component provides a style variant that corresponds (at least partially) to what you're after;
131132
* *Style Properties*: customize the component using <<{articles}/styling/styling-components#theme-style-properties,theme>> and/or <<{articles}/styling/styling-components#component-style-properties,component style properties>>;
132-
* *CSS style blocks*: <<{articles}/styling/styling-components#writing-css-for-vaadin-components,write your own CSS>> (using documented selectors) only once you cant get further with the above approaches.
133+
* *CSS style blocks*: <<{articles}/styling/styling-components#writing-css-for-vaadin-components,write your own CSS>> (using documented selectors) only once you can't get further with the above approaches.
133134

134135
.Shadow DOM Styling Not Recommended
135136
[NOTE]
@@ -149,7 +150,7 @@ warningBox.addClassNames("bg-orange-400 p-20px");
149150

150151
== Inline Styles
151152

152-
Inline CSS can also be applied to individual elements and components through the [methodname]`getStyle()` Java API. These should be used sparingly to avoid hard-to-maintain spaghetti code, but can be useful e.g. for applying styles dynamically based on business logic.
153+
Inline CSS can also be applied to individual elements and components through the [methodname]`getStyle()` Java API. These should be used sparingly to avoid hard-to-maintain spaghetti code, but can be useful, for example, for applying styles dynamically based on business logic.
153154

154155
[source,java]
155156
----

articles/styling/stylesheets.adoc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ In most project configurations, <<{articles}/styling/stylesheets#, stylesheets>>
1313

1414
In both cases they are loaded with the [annotationname]`@StyleSheet` annotation.
1515

16-
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.
16+
Usually, 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.
1717

1818
[source,java]
1919
----
@@ -52,7 +52,7 @@ public class Application implements AppShellConfigurator {}
5252

5353
== External Stylesheets
5454

55-
All of the above methods for loading stylesheets also allow you to load stylesheets from external URIs, including other domains, by supplying an absolute path to [annotationname]`@StyleSheet` or `@import`.
55+
All methods mentioned before for loading stylesheets also allow you to load stylesheets from external URIs, including other domains, by supplying an absolute path to [annotationname]`@StyleSheet` or `@import`.
5656

5757
[source,java]
5858
----
@@ -63,7 +63,7 @@ public class Application implements AppShellConfigurator {
6363
}
6464
----
6565

66-
.src/main/resources/META-INF/resources/styles.css
66+
.`src/main/resources/META-INF/resources/styles.css`
6767
[source,css]
6868
----
6969
@import "https://example.com/external-styles.css";
@@ -73,7 +73,7 @@ You can link:https://developer.mozilla.org/en-US/docs/Web/CSS/@import[read more
7373

7474
== Lazy-Loading Stylesheets
7575

76-
If you want to delay the loading of a particular stylesheet until its needed – for example if the stylesheet is big and only needed in a particular view or Flow component – you can apply the [annotationname]`@StyleSheet` annotation to its class instead of the main application class.
76+
If you want to delay the loading of a particular stylesheet until it's needed – for example if the stylesheet is big and only needed in a particular view or Flow component – you can apply the [annotationname]`@StyleSheet` annotation to its class instead of the main application class.
7777

7878
[source,java]
7979
----
@@ -83,7 +83,7 @@ public class CalendarView extends VerticalLayout {
8383
}
8484
----
8585

86-
Note that the stylesheet will remain loaded even after the user navigates away from the view, or when the component is no longer displayed, so you still need to ensure that the styles in it are scoped appropriately. You can use CSS class names to scope styles to a particular view or other part of the UI.
86+
The stylesheet remains loaded even after the user navigates away from the view, or when the component is no longer displayed. This means you still need to ensure that the styles in it are scoped appropriately. You can use CSS class names to scope styles to a particular view or other part of the UI.
8787

8888
[source,java]
8989
----
@@ -95,7 +95,7 @@ public class CalendarView extends VerticalLayout {
9595
}
9696
----
9797

98-
.src/main/resources/META-INF/resources/calendar-view.css
98+
.`src/main/resources/META-INF/resources/calendar-view.css`
9999
[source,css]
100100
----
101101
.calendar-view {
@@ -108,15 +108,15 @@ public class CalendarView extends VerticalLayout {
108108

109109
.CSS Class Names
110110
[NOTE]
111-
CSS class names are identifier-attributes applied to HTML elements in order to scope CSS styling to them. The same class name can be applied to multiple elements, and each element can have multiple class names. They have nothing to do with Java or TypeScript classes.
111+
CSS class names are identifier-attributes applied to HTML elements that scope CSS styling to them. The same class name can be applied to multiple elements, and each element can have multiple class names. They have nothing to do with Java or TypeScript classes.
112112

113113
Stylesheets can also be <<{articles}/styling/advanced/dynamic-stylesheets#, loaded and unloaded dynamically>> through Java code.
114114

115115
== Spring Security
116116

117117
If you are using <<{articles}/flow/security/enabling-security#, Spring Security>> in your Vaadin application, you need to ensure that your stylesheets are accessible to unauthenticated users. The default Vaadin Spring Security configuration only permits access to `src/main/resources/META-INF/resources/styles.css` as well as the Aura and Lumo theme stylesheets.
118118

119-
To allow access to additional stylesheets, you can modify your Spring Security configuration like so:
119+
To allow access to more stylesheets, you can modify your Spring Security configuration like so:
120120

121121
[source,java]
122122
----
@@ -143,7 +143,7 @@ public class SecurityConfig {
143143

144144
This allows access to common locations for static resources, one of which is the `css` path. To make stylesheets available under that path, place them in the `src/main/resources/META-INF/resources/css` folder. For example, if you place a stylesheet in `src/main/resources/META-INF/resources/css/additional-styles.css`, you can import it in your main stylesheet like so:
145145

146-
.src/main/resources/META-INF/resources/styles.css
146+
.`src/main/resources/META-INF/resources/styles.css`
147147
[source,css]
148148
----
149149
@import "css/additional-styles.css";
-237 KB
Loading
-177 KB
Loading
-317 KB
Binary file not shown.
-189 KB
Loading
166 KB
Loading

0 commit comments

Comments
 (0)