Class TabSheet

  • All Implemented Interfaces:
    com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasSize, com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasTheme, HasThemeVariant<TabSheetVariant>, Serializable

    @Tag("vaadin-tabsheet")
    @NpmPackage(value="@vaadin/tabsheet",
                version="23.6.2")
    @JsModule("@vaadin/tabsheet/src/vaadin-tabsheet.js")
    public class TabSheet
    extends com.vaadin.flow.component.Component
    implements com.vaadin.flow.component.HasStyle, com.vaadin.flow.component.HasSize, HasThemeVariant<TabSheetVariant>
    TabSheet consists of a set of tabs and the content area. The content area displays a component associated with the selected tab.
    Author:
    Vaadin Ltd.
    See Also:
    Serialized Form
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  TabSheet.SelectedChangeEvent
      An event to mark that the selected tab has changed.
    • Constructor Summary

      Constructors 
      Constructor Description
      TabSheet()
      The default constructor.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      Tab add​(com.vaadin.flow.component.Component tabContent, com.vaadin.flow.component.Component content)
      Adds a tab created from the given tab content and content.
      Tab add​(Tab tab, com.vaadin.flow.component.Component content)
      Adds a tab with the given content.
      Tab add​(Tab tab, com.vaadin.flow.component.Component content, int position)
      Adds a tab with the given content to the given position.
      Tab add​(String tabText, com.vaadin.flow.component.Component content)
      Adds a tab created from the given text and content.
      com.vaadin.flow.shared.Registration addSelectedChangeListener​(com.vaadin.flow.component.ComponentEventListener<TabSheet.SelectedChangeEvent> listener)
      Adds a listener for TabSheet.SelectedChangeEvent.
      int getIndexOf​(Tab tab)
      Returns the index of the given tab.
      com.vaadin.flow.component.Component getPrefixComponent()
      Gets the component in the prefix slot of this component.
      int getSelectedIndex()
      Gets the zero-based index of the currently selected tab.
      Tab getSelectedTab()
      Gets the currently selected tab.
      com.vaadin.flow.component.Component getSuffixComponent()
      Gets the component in the suffix slot of this component.
      Tab getTabAt​(int position)
      Returns the tab at the given position.
      void remove​(int position)
      Removes the tab at the given position.
      void remove​(com.vaadin.flow.component.Component content)
      Removes a tab based on the content
      void remove​(Tab tab)
      Removes a tab.
      void setPrefixComponent​(com.vaadin.flow.component.Component component)
      Adds the given component as the prefix of this component, replacing any existing prefix component.
      void setSelectedIndex​(int selectedIndex)
      Selects a tab based on its zero-based index.
      void setSelectedTab​(Tab selectedTab)
      Selects the given tab.
      void setSuffixComponent​(com.vaadin.flow.component.Component component)
      Adds the given component as the suffix of this component, replacing any existing suffix component.
      • 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, scrollIntoView, set, setElement, setId, setVisible
      • Methods inherited from interface com.vaadin.flow.component.AttachNotifier

        addAttachListener
      • Methods inherited from interface com.vaadin.flow.component.DetachNotifier

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

        getElement
      • 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
      • Methods inherited from interface com.vaadin.flow.component.HasTheme

        addThemeName, addThemeNames, getThemeName, getThemeNames, hasThemeName, removeThemeName, removeThemeNames, setThemeName, setThemeName
    • Constructor Detail

      • TabSheet

        public TabSheet()
        The default constructor.
    • Method Detail

      • add

        public Tab add​(String tabText,
                       com.vaadin.flow.component.Component content)
        Adds a tab created from the given text and content.
        Parameters:
        tabText - the text of the tab
        content - the content related to the tab
        Returns:
        the created tab
      • add

        public Tab add​(com.vaadin.flow.component.Component tabContent,
                       com.vaadin.flow.component.Component content)
        Adds a tab created from the given tab content and content.
        Parameters:
        tabContent - the content of the tab
        content - the content related to the tab
        Returns:
        the created tab
      • add

        public Tab add​(Tab tab,
                       com.vaadin.flow.component.Component content)
        Adds a tab with the given content.
        Parameters:
        tab - the tab
        content - the content related to the tab
        Returns:
        the added tab
      • add

        public Tab add​(Tab tab,
                       com.vaadin.flow.component.Component content,
                       int position)
        Adds a tab with the given content to the given position.
        Parameters:
        tab - the tab
        content - the content related to the tab
        position - the position where the tab should be added. If negative, the tab is added at the end.
        Returns:
        the added tab
      • remove

        public void remove​(Tab tab)
        Removes a tab.
        Parameters:
        tab - the non-null tab to be removed
      • remove

        public void remove​(com.vaadin.flow.component.Component content)
        Removes a tab based on the content
        Parameters:
        content - the non-null content related to the tab to be removed
      • remove

        public void remove​(int position)
        Removes the tab at the given position.
        Parameters:
        position - the position of the tab to be removed
      • getSelectedIndex

        public int getSelectedIndex()
        Gets the zero-based index of the currently selected tab.
        Returns:
        the zero-based index of the selected tab, or -1 if none of the tabs is selected
      • setSelectedIndex

        public void setSelectedIndex​(int selectedIndex)
        Selects a tab based on its zero-based index.
        Parameters:
        selectedIndex - the zero-based index of the selected tab, -1 to unselect all
      • getSelectedTab

        public Tab getSelectedTab()
        Gets the currently selected tab.
        Returns:
        the selected tab, or null if none is selected
      • setSelectedTab

        public void setSelectedTab​(Tab selectedTab)
        Selects the given tab.
        Parameters:
        selectedTab - the tab to select, null to unselect all
        Throws:
        IllegalArgumentException - if selectedTab is not a child of this component
      • getTabAt

        public Tab getTabAt​(int position)
        Returns the tab at the given position.
        Parameters:
        index - the position of the tab, must be greater than or equals to 0 and less than the number of tabs
        Returns:
        The tab at the given index
        Throws:
        IllegalArgumentException - if the index is less than 0 or greater than or equals to the number of tabs
      • getIndexOf

        public int getIndexOf​(Tab tab)
        Returns the index of the given tab.
        Parameters:
        tab - the tab to look up, can not be null
        Returns:
        the index of the tab or -1 if the tab is not added
      • addSelectedChangeListener

        public com.vaadin.flow.shared.Registration addSelectedChangeListener​(com.vaadin.flow.component.ComponentEventListener<TabSheet.SelectedChangeEvent> listener)
        Adds a listener for TabSheet.SelectedChangeEvent.
        Parameters:
        listener - the listener to add, not null
        Returns:
        a handle that can be used for removing the listener
      • setPrefixComponent

        public void setPrefixComponent​(com.vaadin.flow.component.Component component)
        Adds the given component as the prefix of this component, replacing any existing prefix component.
        Parameters:
        component - the component to set, can be null to remove existing prefix component
      • getPrefixComponent

        public com.vaadin.flow.component.Component getPrefixComponent()
        Gets the component in the prefix slot of this component.
        Returns:
        the prefix component of this component, or null if no prefix component has been set
        See Also:
        setPrefixComponent(Component)
      • setSuffixComponent

        public void setSuffixComponent​(com.vaadin.flow.component.Component component)
        Adds the given component as the suffix of this component, replacing any existing suffix component.

        This is most commonly used to add a simple icon or static text into the component.

        Parameters:
        component - the component to set, can be null to remove existing suffix component
      • getSuffixComponent

        public com.vaadin.flow.component.Component getSuffixComponent()
        Gets the component in the suffix slot of this component.
        Returns:
        the suffix component of this component, or null if no suffix component has been set
        See Also:
        setPrefixComponent(Component)