Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Where to put the style.css
Hey there, I have written the following code:
`package com.example.vaadin_chart2;
import com.vaadin.annotations.StyleSheet; import com.vaadin.server.VaadinRequest; import com.vaadin.spring.annotation.SpringUI; import com.vaadin.ui.*;
@StyleSheet("style.css")
@SpringUI public class ChartUI extends UI { CssLayout layout;
@Override
protected void init(VaadinRequest vaadinRequest) {
setupLayout();
}
private void setupLayout() {
layout= new CssLayout();
setContent(layout);
Label l = new Label();
l.addStyleName("Head");
layout.addComponent(l);
Button button = new Button("button");
layout.addComponent(button);
}
} ` I tried to include the css via the annotation, but i doesn't work out (no black square). Somewhere I have read i should overwrite the css in the Vaadin directory, but i have no such directory in my source path. I have downloaded the project folder and dependencies from start.spring.io .
Here is the css, which is in the same directory as the java class :
.v-label-Head{
width: 20px;
height: 20px;
color: black;
}
Greetings Julian
There are several options, for example:
-
Put the CSS file in the
src/main/webapp/VAADIN/*
directory and use@StyleSheet("vaadin://style.css")
. -
Put the css file in the
src/main/resources/com/example/demo/
directory and use @StyleSheet("style.css").
You might want to consider using a theme. This video might help:
Thanks for answering, but i cant find a webapp folder in my main folder.. Should i maybe use something else as start.spring.io to setup the project?
Or can i simply create the folder?
omg it's working this is so cool (and easy) Thank you :)