Class FlexLayout

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.orderedlayout.FlexLayout
All Implemented Interfaces:
AttachNotifier, ClickNotifier<FlexLayout>, DetachNotifier, HasComponents, HasElement, HasEnabled, HasOrderedComponents, HasSize, HasStyle, FlexComponent, Serializable

@Tag("div") public class FlexLayout extends Component implements FlexComponent, ClickNotifier<FlexLayout>
A layout component that implements Flexbox. It uses the default flex-direction and doesn't have any predetermined width or height.

This component can be used as a base class for more advanced layouts.

See Also:
  • Constructor Details

    • FlexLayout

      public FlexLayout()
      Default constructor. Creates an empty layout.
    • FlexLayout

      public FlexLayout(Component... children)
      Convenience constructor to create a layout with the children already inside it.
      Parameters:
      children - the items to add to this layout
      See Also:
  • Method Details

    • setFlexWrap

      public void setFlexWrap(FlexLayout.FlexWrap flexWrap)
      Gets the FlexLayout.FlexWrap used by this layout.

      The default flex wrap is FlexLayout.FlexWrap.NOWRAP.

      Parameters:
      flexWrap - the flex wrap of the layout, never null
    • getFlexWrap

      public FlexLayout.FlexWrap getFlexWrap()
      Gets the current flex wrap of the layout.

      The default flex wrap is FlexLayout.FlexWrap.NOWRAP.

      Returns:
      the flex wrap used by the layout, never null
    • setAlignContent

      public void setAlignContent(FlexLayout.ContentAlignment alignment)
      Similar to FlexComponent.setAlignItems(Alignment), but instead of aligning components, it aligns flex lines.

      It effectively sets the "alignContent" style value.

      The default alignment is FlexLayout.ContentAlignment.STRETCH.

      Parameters:
      alignment - the alignment to apply to the components. Setting null will reset the alignment to its default
    • getAlignContent

      public FlexLayout.ContentAlignment getAlignContent()
      Gets the current align content property of the layout.
      Returns:
      the align content property, or FlexLayout.ContentAlignment.STRETCH if none was set
    • setFlexBasis

      public void setFlexBasis(String width, HasElement... components)
      Sets the flex basis property of the components inside the layout. The flex basis property specifies the initial main size of a component.
      Parameters:
      width - the width for the components. Setting null will remove the flex basis property
      components - the components to apply the flex basis property
    • getFlexBasis

      public String getFlexBasis(HasElement component)
      Gets the flex basis property of a given component.
      Parameters:
      component - the component to read the flex basis property from
      Returns:
      the flex grow property
    • setFlexDirection

      public void setFlexDirection(FlexLayout.FlexDirection flexDirection)
      Sets the flex direction property of the layout. The flex direction property specifies how components are placed in the layout defining the main axis and the direction (normal or reversed). The default direction is FlexLayout.FlexDirection.ROW.
      Parameters:
      flexDirection - the direction for the components. Setting null will remove the flex direction property
    • getFlexDirection

      public FlexLayout.FlexDirection getFlexDirection()
      Gets the flex direction property of the layout.
      Returns:
      the flex direction property, or FlexLayout.FlexDirection.ROW if none was set
    • setOrder

      public void setOrder(int order, HasElement component)
      Sets the order property of the component inside the layout. The order property specifies the order of a component relative to the rest of the components inside the same layout. The default value is 0, and setting 0 can be used to remove an existing order for a component.
      Parameters:
      order - the order for the component
      component - the component to apply the order property
    • getOrder

      public int getOrder(HasElement component)
      Gets the order property of a given component.
      Parameters:
      component - the component to read the order property from
      Returns:
      the order property, or 0 if none was set