A form layout layouts children in columns.

  • Fluent
  • Declarative

    FormLayout.builder()
            .content(List.of(
                    FormRow.builder()
                            .content(List.of(
                                    FormField.builder()
                                            .dataType(FieldDataType.string)
                                            .label("Name")
                                            .build(),
                                    FormField.builder()
                                            .dataType(FieldDataType.integer)
                                            .label("Age")
                                            .build(),
                                    FormField.builder()
                                            .dataType(FieldDataType.bool)
                                            .label("Registered")
                                            .build()
                            ))
                            .build()
            ))
            .autoResponsive(true)
            .maxColumns(2)
            .build()

    @FormColumns(2)
    class MyForm {
        
        String name;
        
        int age;
        
        boolean registered;
  
    }
    

Available properties

This is the list of available properties for a form layout:

PropertyDescriptionNotes
idid for this component
cssClasseslist of css classescontent of the css attribute
styleinline style attributescontent of the style attribute
autoResponsiveto make the form responsive according to columns widthtrue/false
labelsAsideto place the labels at left, inside top of fieldtrue/false
fullWidthshortcut to set width:100%true/false
columnWidthcolumn widthpx, em, rem, …
expandColumnsexpand columnstrue/false
expandFieldsexpand fieldstrue/false
maxColumnsmax columns in a rownumber
responsiveStepsfine grained responsive stepslook at Vaadin doc
columnSpacingspace between columnspx, em, rem, …
rowSpacingspace between rowspx, em, rem, …
labelSpacingspace between label and rowpx, em, rem, …

You can see a full explanation of those properties at https://vaadin.com/docs/latest/components/form-layout