com.vaadin.flow.component.orderedlayout.

Class HorizontalLayout

    • Constructor Detail

      • HorizontalLayout

        public HorizontalLayout()

        Constructs an empty layout with spacing on by default.

      • HorizontalLayout

        public HorizontalLayout(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 horizontal layout.

        Specified by:

        setSpacing in interface ThemableLayout

        Parameters:

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

      • setVerticalComponentAlignment

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

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

        It effectively sets the "alignSelf" style value.

        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

        See Also:

        FlexComponent.setAlignSelf(Alignment, HasElement...)

      • getVerticalComponentAlignment

        public FlexComponent.Alignment getVerticalComponentAlignment(Component component)

        Gets the individual vertical 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)

      • setDefaultVerticalComponentAlignment

        public void setDefaultVerticalComponentAlignment(FlexComponent.Alignment alignment)

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

        It effectively sets the "alignItems" style value.

        The default alignment is Alignment#START.

        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

        See Also:

        FlexComponent.setAlignItems(Alignment)

      • getDefaultVerticalComponentAlignment

        public FlexComponent.Alignment getDefaultVerticalComponentAlignment()

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

        The default alignment is Alignment#STRETCH.

        This is 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 #setDefaultVerticalComponentAlignment(Alignment).

        Specified by:

        setAlignItems in interface FlexComponent<HorizontalLayout>

        Parameters:

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

        See Also:

        #setDefaultVerticalComponentAlignment(Alignment)

      • setAlignSelf

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

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

        Specified by:

        setAlignSelf in interface FlexComponent<HorizontalLayout>

        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:

        #setVerticalComponentAlignment(Alignment, Component...)