I'm trying to migrate an existing Vaadin 8 application to Vaadin 12 and need to know how to recreate the functionality of Vaadin 8's GridLayout in Vaadin 12.
According to Vaadin Docs a GridLayout can be replaced in Vaadin 12 by: "Use Div together with the new CSS Grid functionality that is supported in most browsers"
Unfortunately it's not totally clear how exactly this can be done.
Lets assume that I have a Vaadin composite "HelloGrid":
@StyleSheet("styles/hello-grid.css")
public class HelloGrid extends Composite<Div> {
public HelloGrid(){
// EDIT: This line is my solution to the question
getElement().getClassList().add("hello-grid");
Label labelOne = new Label();
labelOne.addClassName("label-one");
Label labelTwo = new Label();
labelTwo.addClassName("label-two");
add(labelOne);
add(labelTwo);
}
}
And a css file "hello-grid.css":
.hello-grid {
display: grid !important;
grid-template-rows: auto;
grid-template-columns: 1fr 1fr;
}
.label-one {
grid-column: 1;
}
.label-two {
grid-column: 2;
}
- How can I associate the ".hello-grid" css class with the HelloGrid Composite.
- Is this the right/preferred way to use a css grid in Vaadin 12 at all