Documentation versions (currently viewingVaadin 8)

Vaadin 8 reached End of Life on February 21, 2022. Discover how to make your Vaadin 8 app futureproof →


The user interface components in Vaadin can roughly be divided in two groups: components that the user can interact with and layout components for placing the other components to specific places in the user interface. The layout components are identical in their purpose to layout managers in regular desktop frameworks for Java. You can use plain Java to accomplish sophisticated component layouts.

layout intro example 1
Layout example

You start by creating a content layout for the UI and then add other layout components hierarchically, and finally the interaction components as the leaves of the component tree.

layout schematic
Layout schematic

Let us look at building a bit simplified version of the layout in Layout example:

// Set the root layout for the UI
VerticalLayout content = new VerticalLayout();

HorizontalLayout titleBar = new HorizontalLayout();

Label title = new Label("The Ultimate Cat Finder");
titleBar.setExpandRatio(title, 1.0f); // Expand

Label titleComment = new Label("for Vaadin");
titleComment.setSizeUndefined(); // Take minimum space

... build rest of the layout ...

Or in the declarative format (roughly):

  <vaadin-label>The Ultimate Cat Finder</vaadin-label>

    <vaadin-radio-button-group caption="Possible Places"/>

You will usually need to tune the layout components a bit by setting sizes, expansion ratios, alignments, spacings, and so on. The general settings are described in "Layout Formatting".

Layouts are coupled with themes that specify various layout features, such as backgrounds, borders, text alignment, and so on. Definition and use of themes is described in "Themes".

You can see a finished version of the above example in Layout example.