Interface FlexComponent

All Superinterfaces:
com.vaadin.flow.component.HasComponents, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasEnabled, com.vaadin.flow.component.HasOrderedComponents, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, Serializable
All Known Implementing Classes:
FlexLayout, HorizontalLayout, VerticalLayout

public interface FlexComponent extends com.vaadin.flow.component.HasOrderedComponents, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasSize
A component which implements Flexbox.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static enum 
    Enum with the possible values for the component alignment inside the layout.
    static enum 
    Enum with the possible values for the way the extra space inside the layout is distributed among the components.
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    expand(com.vaadin.flow.component.Component... componentsToExpand)
    Expands the given components.
    Gets the default alignment used by all components without individual alignments inside the layout.
    getAlignSelf(com.vaadin.flow.component.HasElement component)
    Gets the individual alignment of a given component.
    default double
    getFlexGrow(com.vaadin.flow.component.HasElement component)
    Gets the flex grow property of a given component.
    default double
    getFlexShrink(com.vaadin.flow.component.HasElement component)
    Gets the flex shrink property of a given component.
    Gets the current justify content mode of the layout.
    default void
    replace(com.vaadin.flow.component.Component oldComponent, com.vaadin.flow.component.Component newComponent)
     
    default void
    Sets the default alignment to be used by all components without individual alignments inside the layout.
    default void
    setAlignSelf(FlexComponent.Alignment alignment, com.vaadin.flow.component.HasElement... components)
    Sets an alignment for individual components inside the layout.
    default void
    setFlexGrow(double flexGrow, com.vaadin.flow.component.HasElement... components)
    Sets the flex grow property of the components inside the layout.
    default void
    setFlexShrink(double flexShrink, com.vaadin.flow.component.HasElement... components)
    Sets the flex shrink property of the components inside the layout.
    default void
    Sets the FlexComponent.JustifyContentMode used by this layout.

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

    add, add, add, addComponentAsFirst, addComponentAtIndex, remove, remove, removeAll

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

    getElement

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

    isEnabled, setEnabled

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

    getChildren, getComponentAt, getComponentCount, indexOf

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

    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, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
  • Method Details

    • setAlignItems

      default void setAlignItems(FlexComponent.Alignment alignment)
      Sets the default alignment to be used by all components without individual alignments inside the layout. Individual components can be aligned by using the setAlignSelf(Alignment, HasElement...) method.

      It effectively sets the "alignItems" style value.

      The default alignment is FlexComponent.Alignment.STRETCH.

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

      default FlexComponent.Alignment getAlignItems()
      Gets the default alignment used by all components without individual alignments inside the layout.

      The default alignment is FlexComponent.Alignment.STRETCH.

      Returns:
      the general alignment used by the layout, never null
    • setAlignSelf

      default void setAlignSelf(FlexComponent.Alignment alignment, com.vaadin.flow.component.HasElement... components)
      Sets an alignment for individual components inside the layout. This individual alignment for the component overrides any alignment set at the setAlignItems(Alignment).

      It effectively sets the "alignSelf" style value.

      The default alignment for individual components is FlexComponent.Alignment.AUTO.

      Parameters:
      alignment - the individual alignment for the children components. Setting null will reset the alignment to its default
      components - The components to which the individual alignment should be set
    • getAlignSelf

      default FlexComponent.Alignment getAlignSelf(com.vaadin.flow.component.HasElement component)
      Gets the individual alignment of a given component.

      The default alignment for individual components is FlexComponent.Alignment.AUTO.

      Parameters:
      component - The component which individual layout should be read
      Returns:
      the alignment of the component, never null
    • setFlexGrow

      default void setFlexGrow(double flexGrow, com.vaadin.flow.component.HasElement... components)
      Sets the flex grow property of the components inside the layout. The flex grow property specifies what amount of the available space inside the layout the component should take up, proportionally to the other components.

      For example, if all components have a flex grow property value set to 1, the remaining space in the layout will be distributed equally to all components inside the layout. If you set a flex grow property of one component to 2, that component will take twice the available space as the other components, and so on.

      Setting to flex grow property value 0 disables the expansion of the component. Negative values are not allowed.

      Parameters:
      flexGrow - the proportion of the available space the component should take up
      components - the components to apply the flex grow property
    • getFlexGrow

      default double getFlexGrow(com.vaadin.flow.component.HasElement component)
      Gets the flex grow property of a given component.
      Parameters:
      component - the component to read the flex grow property from
      Returns:
      the flex grow property, or 0 if none was set
    • setFlexShrink

      default void setFlexShrink(double flexShrink, com.vaadin.flow.component.HasElement... components)
      Sets the flex shrink property of the components inside the layout. The flex shrink property specifies how the item will shrink relative to the rest of the components inside the same layout.

      Negative values are not allowed.

      The default value is 1.

      Parameters:
      flexShrink - how much the component will shrink relative to the rest of the components
      components - the components to apply the flex shrink property
    • getFlexShrink

      default double getFlexShrink(com.vaadin.flow.component.HasElement component)
      Gets the flex shrink property of a given component.
      Parameters:
      component - the component to read the flex shrink property from
      Returns:
      the flex shrink property, or 1 if none was set
    • setJustifyContentMode

      default void setJustifyContentMode(FlexComponent.JustifyContentMode justifyContentMode)
      Sets the FlexComponent.JustifyContentMode used by this layout.

      The default justify content mode is FlexComponent.JustifyContentMode.START.

      Parameters:
      justifyContentMode - the justify content mode of the layout, never null
    • getJustifyContentMode

      default FlexComponent.JustifyContentMode getJustifyContentMode()
      Gets the current justify content mode of the layout.

      The default justify content mode is FlexComponent.JustifyContentMode.START.

      Returns:
      the justify content mode used by the layout, never null
    • expand

      default void expand(com.vaadin.flow.component.Component... componentsToExpand)
      Expands the given components.

      It effectively sets 1 as a flex grow property value for each component.

      Parameters:
      componentsToExpand - components to expand
    • replace

      default void replace(com.vaadin.flow.component.Component oldComponent, com.vaadin.flow.component.Component newComponent)
      Specified by:
      replace in interface com.vaadin.flow.component.HasOrderedComponents