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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum with the possible values for the component alignment inside the layout.static enumPossible values for theflex-directionCSS property, which determines how the elements are placed inside the layout.static enumPossible values for theflex-wrapCSS property, which determines how the elements inside the layout should behave when they don't fit inside the layout.Nested classes/interfaces inherited from interface com.vaadin.flow.component.orderedlayout.FlexComponent
FlexComponent.Alignment, FlexComponent.JustifyContentMode -
Constructor Summary
ConstructorsConstructorDescriptionDefault constructor.FlexLayout(Component... children) Convenience constructor to create a layout with the children already inside it. -
Method Summary
Modifier and TypeMethodDescriptionGets the current align content property of the layout.getFlexBasis(HasElement component) Gets the flex basis property of a given component.Gets the flex direction property of the layout.Gets the current flex wrap of the layout.intgetOrder(HasElement component) Gets the order property of a given component.voidsetAlignContent(FlexLayout.ContentAlignment alignment) Similar toFlexComponent.setAlignItems(Alignment), but instead of aligning components, it aligns flex lines.voidsetFlexBasis(String width, HasElement... components) Sets the flex basis property of the components inside the layout.voidsetFlexDirection(FlexLayout.FlexDirection flexDirection) Sets the flex direction property of the layout.voidsetFlexWrap(FlexLayout.FlexWrap flexWrap) Gets theFlexLayout.FlexWrapused by this layout.voidsetOrder(int order, HasElement component) Sets the order property of the component inside the layout.Methods inherited from class com.vaadin.flow.component.Component
addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisibleMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.vaadin.flow.component.AttachNotifier
addAttachListenerMethods inherited from interface com.vaadin.flow.component.ClickNotifier
addClickListener, addClickShortcut, addDoubleClickListener, addSingleClickListenerMethods inherited from interface com.vaadin.flow.component.DetachNotifier
addDetachListenerMethods inherited from interface com.vaadin.flow.component.orderedlayout.FlexComponent
expand, getAlignItems, getAlignSelf, getFlexGrow, getFlexShrink, getJustifyContentMode, replace, setAlignItems, setAlignSelf, setFlexGrow, setFlexShrink, setJustifyContentModeMethods inherited from interface com.vaadin.flow.component.HasComponents
add, add, add, addComponentAsFirst, addComponentAtIndex, remove, remove, removeAllMethods inherited from interface com.vaadin.flow.component.HasElement
getElementMethods inherited from interface com.vaadin.flow.component.HasEnabled
isEnabled, setEnabledMethods inherited from interface com.vaadin.flow.component.HasOrderedComponents
getChildren, getComponentAt, getComponentCount, indexOfMethods 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, setWidthFullMethods inherited from interface com.vaadin.flow.component.HasStyle
addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
-
Constructor Details
-
FlexLayout
public FlexLayout()Default constructor. Creates an empty layout. -
FlexLayout
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
Gets theFlexLayout.FlexWrapused by this layout.The default flex wrap is
FlexLayout.FlexWrap.NOWRAP.- Parameters:
flexWrap- the flex wrap of the layout, nevernull
-
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
Similar toFlexComponent.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. Settingnullwill reset the alignment to its default
-
getAlignContent
Gets the current align content property of the layout.- Returns:
- the align content property, or
FlexLayout.ContentAlignment.STRETCHif none was set
-
setFlexBasis
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. Settingnullwill remove the flex basis propertycomponents- the components to apply the flex basis property
-
getFlexBasis
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
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 isFlexLayout.FlexDirection.ROW.- Parameters:
flexDirection- the direction for the components. Settingnullwill remove the flex direction property
-
getFlexDirection
Gets the flex direction property of the layout.- Returns:
- the flex direction property, or
FlexLayout.FlexDirection.ROWif none was set
-
setOrder
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 componentcomponent- the component to apply the order property
-
getOrder
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
-