Class FormLayout

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.formlayout.FormLayout
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.ClickNotifier<FormLayout>, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasComponents, com.vaadin.flow.component.HasComponentsOfType<com.vaadin.flow.component.Component>, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, Serializable

@Tag("vaadin-form-layout") @NpmPackage(value="@vaadin/form-layout", version="25.4.0-dev.c9532cd333") @JsModule("@vaadin/form-layout/src/vaadin-form-layout.js") public class FormLayout extends com.vaadin.flow.component.Component implements com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasComponents, com.vaadin.flow.component.ClickNotifier<FormLayout>
Form Layout allows you to build responsive forms with multiple columns and to position input labels on top or to the side of the input. Form Layout has two columns by default meaning it displays two input fields per line. When the layout width is smaller it adjusts to a single column layout.

You can define how many columns Form Layout should use based on the screen width. A single column layout is preferable to a multi column one. A multi column layout is more prone to cause confusion and to be misinterpreted by the user. However, closely related fields can be placed in line without issue. For example, first and last name, address fields such as postal code and city, as well as ranged input for dates, time, currency, etc.

Best Practices:
Longer forms should be split into smaller, more manageable and user-friendly sections using subheadings, Tabs, Details or separate views when possible. Each section should consist of related content and/or fields.

Also, use the following guidelines for Button placement in forms:

  • Buttons should be placed below the form they’re associated with.
  • Buttons should be aligned left.
  • Primary action first, followed by other actions, in order of importance.

Auto Responsive Mode

To avoid manually dealing with responsive breakpoints, Form Layout provides an auto-responsive mode that automatically creates and adjusts fixed-width columns based on the container's available space.

To control the number of columns and their widths, you can use the following properties:

  • columnWidth - controls the column width (13em by default).
  • maxColumns - controls the maximum number of columns that the layout can create (10 by default).
  • minColumns - controls the minimum number of columns that the layout will create (1 by default).

The auto-responsive mode is disabled by default. To enable it for an individual instance, set the autoResponsive property to true:

 FormLayout formLayout = new FormLayout();
 formLayout.setAutoResponsive(true);
 formLayout.add(new TextField("First name"), new TextField("Last name"));
 formLayout.add(new TextArea("Address"), 2); // colspan 2
 

You can also enable it for all instances by enabling the following feature flag in src/main/resources/vaadin-featureflags.properties:

 com.vaadin.experimental.defaultAutoResponsiveFormLayout = true
 

Organizing Fields into Rows

By default, each field is placed on a new row. To organize fields into rows, you can either:

  • Manually wrap fields into FormLayout.FormRow elements.
  • Enable the autoRows property to let Form Layout automatically arrange fields in available columns, wrapping to a new row when necessary. HTML br elements can be used to force a new row.

Here is an example of using FormLayout.FormRow:

 FormLayout formLayout = new FormLayout();
 formLayout.setAutoResponsive(true);

 FormRow firstRow = new FormRow();
 firstRow.add(new TextField("First name"), new TextField("Last name"));

 FormRow secondRow = new FormRow();
 secondRow.add(new TextArea("Address"), 2); // colspan 2

 formLayout.add(firstRow, secondRow);
 

Expanding Columns and Fields

You can configure Form Layout to expand columns to evenly fill any remaining space after all fixed-width columns have been created. To enable this, set the expandColumns property to true.

Also, Form Layout can stretch fields to make them take up all available space within columns. To enable this, set the expandFields property to true.

Customizing Label Position

By default, Form Layout displays labels above fields. To put labels next to fields, enable the labelsAside property:

 FormLayout formLayout = new FormLayout();
 formLayout.setAutoResponsive(true);
 formLayout.setLabelsAside(true);

 FormRow firstRow = new FormRow();
 firstRow.add(new TextField("First Name"), new TextField("Last Name"));

 FormRow secondRow = new FormRow();
 secondRow.add(new TextArea("Address"), 2); // colspan 2

 formLayout.add(firstRow, secondRow);
 

When there isn't enough space for side labels, Form Layout returns the labels to the default position above the fields.

All Vaadin input field components placed directly in the Form Layout support labels-aside mode out of the box, showing their label next to the field. Checkable fields, such as Checkbox, work differently: their label remains in place, and Form Layout only indents such fields so they align with the input column.

Any other components, such as buttons or custom components, are just placed at the start of the label column. How they should be laid out in this mode is left to the developer and can be handled in one of two ways:

  1. Wrap the component in a FormLayout.FormItem, with or without a label. The Form Item reserves space for the label, so the component ends up in the input column, aligned with the other fields:

     var nameInput = new Input();
     formLayout.addFormItem(nameInput, "Name");
    
     var saveButton = new Button("Save");
     formLayout.addFormItem(saveButton);
     
  2. Write custom CSS. When labels are rendered next to fields, Form Layout sets the has-labels-aside attribute on its host element and the data-form-layout-has-labels-aside attribute on children. You can rely on these attributes to adapt your components to label-aside mode, for example:

     vaadin-button[data-form-layout-has-labels-aside] {
         margin-inline-start: calc(
             var(--vaadin-form-layout-label-width) +
             var(--vaadin-form-layout-label-spacing)
         );
     }
     
Since:
1.0
Author:
Vaadin Ltd
See Also:
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Server-side component for the <vaadin-form-item> element.
    static class 
    Server-side component for the <vaadin-form-row> element.
    static enum 
    Enum for describing the text alignment that is applied to labels when they are positioned next to fields.
    static class 
    A class used in describing the responsive layouting behavior of a FormLayout.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructs an empty layout.
    FormLayout(com.vaadin.flow.component.Component... components)
    Constructs a FormLayout with the given initial components.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(com.vaadin.flow.component.Component component, int colspan)
    Adds a component with the desired colspan.
    addFormItem(com.vaadin.flow.component.Component field)
    Convenience method for creating and adding a new FormItem to this layout that wraps the given field without a label.
    addFormItem(com.vaadin.flow.component.Component field, com.vaadin.flow.component.Component label)
    Convenience method for creating and adding a new FormItem to this layout that wraps the given field with a component as its label.
    addFormItem(com.vaadin.flow.component.Component field, String label)
    Convenience method for creating and adding a new FormItem to this layout that wraps the given field with a label.
    addFormRow(com.vaadin.flow.component.Component... components)
    Convenience method dor creating and adding a new FormLayout.FormRow to this layout.
    int
    getColspan(com.vaadin.flow.component.Component component)
    Gets the colspan of the given component.
    Gets the gap between the columns.
    Gets the width of columns that is used when setAutoResponsive(boolean) is enabled.
    Gets the gap between the label and the field when labels are positioned next to fields.
    Gets the text alignment of labels when they are positioned next to fields.
    Gets the width that labels have when they are positioned next to fields.
    int
    Gets the maximum number of columns that the component can create when #setAutoResponsive(boolean) is enabled.
    int
    Gets the minimum number of columns that the component can create when #setAutoResponsive(boolean) is enabled.
    Get the list of FormLayout.ResponsiveSteps used to configure this layout.
    Gets the gap between the rows.
    boolean
    Gets whether the component is configured to automatically distribute fields across columns when setAutoResponsive(boolean) is enabled.
    boolean
    Gets whether columns are configured to expand to fill remaining space when setAutoResponsive(boolean) is enabled.
    boolean
    Gets whether fields are configured to stretch to take up all available space within columns when setAutoResponsive(boolean) is enabled.
    boolean
    Gets whether the layout is configured to put labels next to fields when setAutoResponsive(boolean) is enabled.
    void
    setAutoResponsive(boolean autoResponsive)
    When set to true, the component automatically creates and adjusts columns based on the container's width.
    void
    setAutoRows(boolean autoRows)
    Sets whether the component should automatically distribute fields across columns by placing each field in the next available column and wrapping to the next row when the current row is full.
    void
    setColspan(com.vaadin.flow.component.Component component, int colspan)
    Sets the colspan of the given component's element.
    void
    setColumnSpacing(float columnSpacing, com.vaadin.flow.component.Unit unit)
    Sets the gap between the columns.
    void
    setColumnSpacing(String columnSpacing)
    Sets the gap between the columns.
    void
    setColumnWidth(float columnWidth, com.vaadin.flow.component.Unit unit)
    Sets the width of columns that the component should use when setAutoResponsive(boolean) is enabled.
    void
    setColumnWidth(String columnWidth)
    Sets the width of columns that the component should use when setAutoResponsive(boolean) is enabled.
    void
    setExpandColumns(boolean expandColumns)
    Sets whether the columns should evenly expand in width to fill any remaining space after all columns have been created.
    void
    setExpandFields(boolean expandFields)
    Sets whether fields should stretch to take up all available space within columns.
    void
    setLabelsAside(boolean labelsAside)
    Sets whether the layout should put labels next to fields.
    void
    setLabelSpacing(float labelSpacing, com.vaadin.flow.component.Unit unit)
    Sets the gap between the label and the field when labels are positioned next to fields.
    void
    setLabelSpacing(String labelSpacing)
    Sets the gap between the label and the field when labels are positioned next to fields.
    void
    Sets the text alignment of labels when they are positioned next to fields.
    void
    setLabelWidth(float width, com.vaadin.flow.component.Unit unit)
    Sets the width that labels have when they are positioned next to fields.
    void
    Sets the width that labels have when they are positioned next to fields.
    void
    setMaxColumns(int maxColumns)
    Sets the maximum number of columns that the component can create.
    void
    setMinColumns(int minColumns)
    Sets the minimum number of columns that the component will create.
    void
    Configure the responsive steps used in this layout.
    void
    Configure the responsive steps used in this layout.
    void
    setRowSpacing(float rowSpacing, com.vaadin.flow.component.Unit unit)
    Sets the gap between the rows.
    void
    setRowSpacing(String rowSpacing)
    Sets the gap between the rows.

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, bindVisible, findAncestor, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTestId, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setTestId, setVisible, whenAttached

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.ClickNotifier

    addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.HasComponents

    add

    Methods inherited from interface com.vaadin.flow.component.HasComponentsOfType

    add, add, addComponentAsFirst, addComponentAtIndex, bindChildren, getChildren, getComponentAt, getComponentCount, indexOf, remove, remove, removeAll, replace

    Methods inherited from interface com.vaadin.flow.component.HasElement

    getElement

    Methods inherited from interface com.vaadin.flow.component.HasEnabled

    bindEnabled, isEnabled, setEnabled

    Methods inherited from interface com.vaadin.flow.component.HasSize

    bindHeight, bindWidth, getHeight, getHeightUnit, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, getWidthUnit, setHeight, setHeight, setHeightFull, setMaxHeight, setMaxHeight, setMaxWidth, setMaxWidth, setMinHeight, setMinHeight, setMinWidth, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidth, setWidthFull

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, bindClassName, bindClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
  • Constructor Details

    • FormLayout

      public FormLayout()
      Constructs an empty layout. Components can be added with HasComponentsOfType.add(Component...).
    • FormLayout

      public FormLayout(com.vaadin.flow.component.Component... components)
      Constructs a FormLayout with the given initial components. Additional components can be added after construction with HasComponentsOfType.add(Component...).
      Parameters:
      components - the components to add
      See Also:
      • HasComponentsOfType.add(Component...)
  • Method Details

    • setColspan

      public void setColspan(com.vaadin.flow.component.Component component, int colspan)
      Sets the colspan of the given component's element. Will default to 1 if an integer lower than 1 is supplied. You can directly add components with the wanted colspan with add(Component, int).
      Parameters:
      component - the component to set the colspan for, not null
      colspan - the desired colspan for the component
      Since:
      2.0
    • add

      public void add(com.vaadin.flow.component.Component component, int colspan)
      Adds a component with the desired colspan. This method is a shorthand for calling HasComponentsOfType.add(Component...) and setColspan(Component, int)
      Parameters:
      component - the component to add
      colspan - the desired colspan for the component
      Since:
      2.0
    • getColspan

      public int getColspan(com.vaadin.flow.component.Component component)
      Gets the colspan of the given component. If none is set, returns 1.
      Parameters:
      component - the component whose colspan is retrieved
      Returns:
      the colspan of the given component or 1 if none is set
      Since:
      2.0
    • getResponsiveSteps

      public List<FormLayout.ResponsiveStep> getResponsiveSteps()
      Get the list of FormLayout.ResponsiveSteps used to configure this layout.
      Returns:
      the list of FormLayout.ResponsiveSteps used to configure this layout
      See Also:
    • setResponsiveSteps

      public void setResponsiveSteps(List<FormLayout.ResponsiveStep> steps)
      Configure the responsive steps used in this layout.

      NOTE: Responsive steps are ignored in auto-responsive mode, which may be enabled explicitly via setAutoResponsive(boolean) or implicitly if the following feature flag is set in src/main/resources/vaadin-featureflags.properties:

       com.vaadin.experimental.defaultAutoResponsiveFormLayout = true
       
      Parameters:
      steps - list of FormLayout.ResponsiveSteps to set
      See Also:
    • setResponsiveSteps

      public void setResponsiveSteps(FormLayout.ResponsiveStep... steps)
      Configure the responsive steps used in this layout.

      NOTE: Responsive steps are ignored in auto-responsive mode, which may be enabled explicitly via setAutoResponsive(boolean) or implicitly if the following feature flag is set in src/main/resources/vaadin-featureflags.properties:

       com.vaadin.experimental.defaultAutoResponsiveFormLayout = true
       
      Parameters:
      steps - the FormLayout.ResponsiveSteps to set
      See Also:
    • addFormItem

      public FormLayout.FormItem addFormItem(com.vaadin.flow.component.Component field)
      Convenience method for creating and adding a new FormItem to this layout that wraps the given field without a label.
      Parameters:
      field - the field component to wrap
      Returns:
      the created form item
      Since:
      25.4
    • addFormItem

      public FormLayout.FormItem addFormItem(com.vaadin.flow.component.Component field, String label)
      Convenience method for creating and adding a new FormItem to this layout that wraps the given field with a label. Shorthand for addFormItem(field, new Label(label)).
      Parameters:
      field - the field component to wrap
      label - the label text to set
      Returns:
      the created form item
      See Also:
    • addFormItem

      public FormLayout.FormItem addFormItem(com.vaadin.flow.component.Component field, com.vaadin.flow.component.Component label)
      Convenience method for creating and adding a new FormItem to this layout that wraps the given field with a component as its label.
      Parameters:
      field - the field component to wrap
      label - the label component to set
      Returns:
      the created form item
    • addFormRow

      public FormLayout.FormRow addFormRow(com.vaadin.flow.component.Component... components)
      Convenience method dor creating and adding a new FormLayout.FormRow to this layout. The method accepts a list of components that will be added to the row.
      Parameters:
      components - the components to add to the row
      Returns:
      the created form row
      Since:
      24.8
    • setLabelWidth

      public void setLabelWidth(String width)
      Sets the width that labels have when they are positioned next to fields.
      Parameters:
      width - the value and CSS unit as a string
      Since:
      24.5
      See Also:
    • setLabelWidth

      public void setLabelWidth(float width, com.vaadin.flow.component.Unit unit)
      Sets the width that labels have when they are positioned next to fields.
      Parameters:
      width - the value of the width
      unit - the CSS unit of the width
      Since:
      24.8
      See Also:
    • getLabelWidth

      public String getLabelWidth()
      Gets the width that labels have when they are positioned next to fields.
      Returns:
      the value and CSS unit as a string
      Since:
      24.5
      See Also:
    • setLabelSpacing

      public void setLabelSpacing(String labelSpacing)
      Sets the gap between the label and the field when labels are positioned next to fields. The value must be provided in CSS length units, e.g. 1em.
      Parameters:
      labelSpacing - the gap between the label and the field
      Since:
      24.8
      See Also:
    • setLabelSpacing

      public void setLabelSpacing(float labelSpacing, com.vaadin.flow.component.Unit unit)
      Sets the gap between the label and the field when labels are positioned next to fields. The value must be provided with a Unit, e.g., 1 and Unit.EM.
      Parameters:
      labelSpacing - the gap between the label and the field
      unit - the CSS unit of the gap
      Since:
      24.8
      See Also:
    • getLabelSpacing

      public String getLabelSpacing()
      Gets the gap between the label and the field when labels are positioned next to fields.
      Returns:
      the value and CSS unit as a string
      Since:
      24.8
      See Also:
    • setLabelTextAlign

      public void setLabelTextAlign(FormLayout.LabelTextAlign labelTextAlign)
      Sets the text alignment of labels when they are positioned next to fields. The default value is FormLayout.LabelTextAlign.START.
      Parameters:
      labelTextAlign - the text alignment of labels, not null
      Since:
      25.4
      See Also:
    • getLabelTextAlign

      public FormLayout.LabelTextAlign getLabelTextAlign()
      Gets the text alignment of labels when they are positioned next to fields. The default value is FormLayout.LabelTextAlign.START.
      Returns:
      the text alignment of labels, never null
      Since:
      25.4
      See Also:
    • setColumnSpacing

      public void setColumnSpacing(String columnSpacing)
      Sets the gap between the columns. The value must be provided in CSS length units, e.g. 1em.
      Parameters:
      columnSpacing - the gap between the columns
      Since:
      24.8
      See Also:
    • setColumnSpacing

      public void setColumnSpacing(float columnSpacing, com.vaadin.flow.component.Unit unit)
      Sets the gap between the columns. The value must be provided with a Unit, e.g. 1 and Unit.EM.
      Parameters:
      columnSpacing - the gap between the columns
      unit - the CSS unit of the gap
      Since:
      24.8
      See Also:
    • getColumnSpacing

      public String getColumnSpacing()
      Gets the gap between the columns.
      Returns:
      the value and CSS unit as a string
      Since:
      24.8
      See Also:
    • setRowSpacing

      public void setRowSpacing(String rowSpacing)
      Sets the gap between the rows. The value must be provided in CSS length units, e.g. 1em.
      Parameters:
      rowSpacing - the gap between the rows
      Since:
      24.8
      See Also:
    • setRowSpacing

      public void setRowSpacing(float rowSpacing, com.vaadin.flow.component.Unit unit)
      Sets the gap between the rows. The value must be provided with a Unit, e.g., 1 and Unit.EM.
      Parameters:
      rowSpacing - the gap between the rows
      unit - the CSS unit of the gap
      Since:
      24.8
      See Also:
    • getRowSpacing

      public String getRowSpacing()
      Gets the gap between the rows.
      Returns:
      the value and CSS unit as a string
      Since:
      24.8
      See Also:
    • setAutoResponsive

      public void setAutoResponsive(boolean autoResponsive)
      When set to true, the component automatically creates and adjusts columns based on the container's width. Columns have a fixed width defined by setColumnWidth(String). The number of columns increases up to the limit set by setMaxColumns(int). The minimum number of columns will be created is set by setMinColumns(int). The component dynamically adjusts the number of columns as the container size changes. When this mode is enabled, Responsive steps are ignored.

      By default, each field is placed on a new row. To organize fields into rows, there are two options:

      1. Use FormLayout.FormRow to explicitly group fields into rows.
      2. Enable the setAutoRows(boolean) property to automatically arrange fields in available columns, wrapping to a new row when necessary. ElementFactory.createBr() elements can be used to force a new row.

      The auto-responsive mode is disabled by default. To enable it for an individual instance, use this method. Alternatively, if you want it to be enabled for all instances by default, enable the following feature flag in src/main/resources/vaadin-featureflags.properties:

       com.vaadin.experimental.defaultAutoResponsiveFormLayout = true
       
      Parameters:
      autoResponsive - true to enable auto responsive mode, false to disable
      Since:
      24.8
    • setAutoRows

      public void setAutoRows(boolean autoRows)
      Sets whether the component should automatically distribute fields across columns by placing each field in the next available column and wrapping to the next row when the current row is full. ElementFactory.createBr() elements can be used to force a new row.

      The default value is false.

      This setting only applies when setAutoResponsive(boolean) is enabled.

      Parameters:
      autoRows - true to enable auto rows mode, false otherwise
      Since:
      24.8
    • isAutoRows

      public boolean isAutoRows()
      Gets whether the component is configured to automatically distribute fields across columns when setAutoResponsive(boolean) is enabled.
      Returns:
      true if auto rows mode is enabled, false otherwise
      Since:
      24.8
      See Also:
    • setColumnWidth

      public void setColumnWidth(String columnWidth)
      Sets the width of columns that the component should use when setAutoResponsive(boolean) is enabled. The value must be provided in CSS length units, e.g. 100px.

      When the column width is null, the web component defaults to 12em or uses the value of --vaadin-field-default-width if that CSS custom property is defined.

      This setting only applies when setAutoResponsive(boolean) is enabled.

      Parameters:
      columnWidth - the width of columns or null to use the default
      Since:
      24.8
    • setColumnWidth

      public void setColumnWidth(float columnWidth, com.vaadin.flow.component.Unit unit)
      Sets the width of columns that the component should use when setAutoResponsive(boolean) is enabled. The value must be provided with a Unit, e.g. 100 and Unit.PIXELS.

      When the column width is null, the web component defaults to 12em or uses the value of --vaadin-field-default-width if that CSS custom property is defined.

      This setting only applies when setAutoResponsive(boolean) is enabled.

      Parameters:
      columnWidth - the width of columns
      unit - the CSS unit of the width
      Since:
      24.8
    • getColumnWidth

      public String getColumnWidth()
      Gets the width of columns that is used when setAutoResponsive(boolean) is enabled.

      When the column width is null, the web component defaults to 12em or uses the value of --vaadin-field-default-width if that CSS custom property is defined.

      Returns:
      the value and CSS unit as a string, or null if not set, in which case the web component uses its default value
      Since:
      24.8
      See Also:
    • setMaxColumns

      public void setMaxColumns(int maxColumns)
      Sets the maximum number of columns that the component can create. The component will create columns up to this limit based on the available container width.

      By default, the web component uses a maximum of 10 columns.

      This setting only applies when setAutoResponsive(boolean) is enabled.

      Parameters:
      maxColumns - the maximum number of columns
      Since:
      24.8
    • getMaxColumns

      public int getMaxColumns()
      Gets the maximum number of columns that the component can create when #setAutoResponsive(boolean) is enabled.
      Returns:
      the maximum number of columns or 0 if not explicitly set
      Since:
      24.8
      See Also:
    • setMinColumns

      public void setMinColumns(int minColumns)
      Sets the minimum number of columns that the component will create.

      By default, the web component uses a minimum of 1 column.

      This setting only applies when setAutoResponsive(boolean) is enabled.

      Parameters:
      minColumns - the minimum number of columns
      Since:
      24.8
    • getMinColumns

      public int getMinColumns()
      Gets the minimum number of columns that the component can create when #setAutoResponsive(boolean) is enabled.
      Returns:
      the minimum number of columns or 0 if not explicitly set
      Since:
      24.8
      See Also:
    • setExpandColumns

      public void setExpandColumns(boolean expandColumns)
      Sets whether the columns should evenly expand in width to fill any remaining space after all columns have been created.

      The default value is false.

      This setting only applies when setAutoResponsive(boolean) is enabled.

      Parameters:
      expandColumns - true to expand columns, false otherwise
      Since:
      24.8
    • isExpandColumns

      public boolean isExpandColumns()
      Gets whether columns are configured to expand to fill remaining space when setAutoResponsive(boolean) is enabled.
      Returns:
      true if columns should expand, false otherwise
      Since:
      24.8
      See Also:
    • setExpandFields

      public void setExpandFields(boolean expandFields)
      Sets whether fields should stretch to take up all available space within columns. Fields inside FormLayout.FormItem elements are also included.

      The default value is false.

      This setting only applies when setAutoResponsive(boolean) is enabled.

      Parameters:
      expandFields - true to expand fields, false otherwise
      Since:
      24.8
    • isExpandFields

      public boolean isExpandFields()
      Gets whether fields are configured to stretch to take up all available space within columns when setAutoResponsive(boolean) is enabled.
      Returns:
      true if fields should expand, false otherwise
      Since:
      24.8
      See Also:
    • setLabelsAside

      public void setLabelsAside(boolean labelsAside)
      Sets whether the layout should put labels next to fields. If the layout is too narrow for a single column with a side label, the labels automatically return to their default position above the fields.

      This setting only applies when setAutoResponsive(boolean) is enabled.

      Parameters:
      labelsAside - true to put labels next to fields, false otherwise
      Since:
      24.8
      See Also:
    • isLabelsAside

      public boolean isLabelsAside()
      Gets whether the layout is configured to put labels next to fields when setAutoResponsive(boolean) is enabled.
      Returns:
      true if labels are put next to fields, false otherwise
      Since:
      24.8
      See Also: