How can I use CSS for Vaadin components?

I seem to see examples where people answer questions about how to get specific behavior from components by adding CSS code, however no one seems to explain how to use this CSS code to connect to Java components ...

.v-table-body{ overflow: hidden !important; } 

How can I use, for example, this code in my table that I create?

 Table table = new Table(caption); table.addContainerProperty("Visit ID", Long.class, null); 
+4
source share
1 answer

You can create your own theme. See https://vaadin.com/book/-/page/themes.creating.html how to do this.

In this thread, you have a CSS stylesheet in which you can put your rules.

On each component, you can use the addStyleName function to add an additional class name:

 Table table = new Table("MyCaption"); table.addStyleName("mystyle"); 

Now you can use this in your stylesheet:

 @import "../reindeer/styles.css"; .mystyle{ overflow: hidden !important; } 
+8
source

All Articles