com.vaadin.flow.component.orderedlayout.

Class VerticalLayout

    • Constructor Detail

      • VerticalLayout

        public VerticalLayout()

        Constructs an empty layout with spacing and padding on by default.

      • VerticalLayout

        public VerticalLayout(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:

        HasComponents.add(Component...)

    • Method Detail

      • setSpacing

        public void setSpacing(boolean spacing)

        Toggles spacing theme setting for the element. If a theme supports this attribute, it will apply or remove spacing to the element.

        This method adds medium spacing to the component theme, to set other options, use ThemableLayout.getThemeList(). List of options possible:

        • spacing-xs
        • spacing-s
        • spacing
        • spacing-l
        • spacing-xl

        Spacing is enabled by default for vertical layout.

        Specified by:

        setSpacing in interface ThemableLayout

        Parameters:

        spacing - adds spacing theme setting if true or removes it if false

      • setPadding

        public void setPadding(boolean padding)

        Toggles padding theme setting for the element. If a theme supports this attribute, it will apply or remove padding to the element.

        Padding is enabled by default for vertical layout.

        Specified by:

        setPadding in interface ThemableLayout

        Parameters:

        padding - adds padding theme setting if true or removes it if false

      • setHorizontalComponentAlignment

        public void setHorizontalComponentAlignment(FlexComponent.Alignment alignment,
                                                    Component... componentsToAlign)

        Sets a horizontal alignment for individual components inside the layout. This individual alignment for the component overrides any alignment set at the #setDefaultHorizontalComponentAlignment(Alignment).

        The default alignment for individual components is Alignment#AUTO.

        It's the same as the FlexComponent.setAlignSelf(Alignment, HasElement...) method.

        Parameters:

        alignment - the individual alignment for the children components. Setting null will reset the alignment to its default

        componentsToAlign - The components to which the individual alignment should be set

      • getHorizontalComponentAlignment

        public FlexComponent.Alignment getHorizontalComponentAlignment(Component component)

        Gets the individual horizontal alignment of a given component.

        The default alignment for individual components is Alignment#AUTO.

        It's the same as the getAlignSelf(HasElement) method

        Parameters:

        component - The component which individual layout should be read

        Returns:

        the alignment of the component, never null

        See Also:

        getAlignSelf(HasElement)

      • setDefaultHorizontalComponentAlignment

        public void setDefaultHorizontalComponentAlignment(FlexComponent.Alignment alignment)

        Sets the default horizontal alignment to be used by all components without individual alignments inside the layout. Individual components can be aligned by using the #setHorizontalComponentAlignment(Alignment, Component...) method.

        The default alignment is Alignment#STRETCH.

        It's the same as the FlexComponent.setAlignItems(Alignment) method.

        Parameters:

        alignment - the alignment to apply to the components. Setting null will reset the alignment to its default

      • getDefaultHorizontalComponentAlignment

        public FlexComponent.Alignment getDefaultHorizontalComponentAlignment()

        Gets the default horizontal alignment used by all components without individual alignments inside the layout.

        The default alignment is Alignment#STRETCH.

        It's the same as the getAlignItems() method.

        Returns:

        the general alignment used by the layout, never null

      • setAlignItems

        public void setAlignItems(FlexComponent.Alignment alignment)

        This is the same as #setDefaultHorizontalComponentAlignment(Alignment).

        Specified by:

        setAlignItems in interface FlexComponent

        Parameters:

        alignment - the alignment to apply to the components. Setting null will reset the alignment to its default

        See Also:

        #setDefaultHorizontalComponentAlignment(Alignment)

      • setAlignSelf

        public void setAlignSelf(FlexComponent.Alignment alignment,
                                 HasElement... elementContainers)

        This is the same as #setHorizontalComponentAlignment(Alignment, Component...).

        Specified by:

        setAlignSelf in interface FlexComponent

        Parameters:

        alignment - the individual alignment for the children components. Setting null will reset the alignment to its default

        elementContainers - The element containers (components) to which the individual alignment should be set

        See Also:

        #setHorizontalComponentAlignment(Alignment, Component...)

      • addAndExpand

        public void addAndExpand(Component... components)

        Adds the given components to this layout and sets them as expanded. The flex-grow of all added child components are set to 1 so that the expansion will be effective. The height of this layout is also set to 100%.

        Parameters:

        components - the components to set, not null