Class Tab

java.lang.Object
com.vaadin.flow.component.Component
com.vaadin.flow.component.tabs.Tab
All Implemented Interfaces:
AttachNotifier, DetachNotifier, HasAriaLabel, HasComponents, HasElement, HasEnabled, HasLabel, HasStyle, HasTheme, HasThemeVariant<TabVariant>, HasTooltip, Serializable

@Tag("vaadin-tab") @NpmPackage(value="@vaadin/polymer-legacy-adapter",version="24.1.2") @NpmPackage(value="@vaadin/tabs",version="24.1.2") @JsModule("@vaadin/polymer-legacy-adapter/style-modules.js") @JsModule("@vaadin/tabs/src/vaadin-tab.js") public class Tab extends Component implements HasAriaLabel, HasComponents, HasLabel, HasStyle, HasThemeVariant<TabVariant>, HasTooltip
This component provides an accessible and customizable tab to be used inside Tabs component.
Author:
Vaadin Ltd.
See Also:
  • Constructor Details

    • Tab

      public Tab()
      Constructs a new object in its default state.
    • Tab

      public Tab(String label)
      Constructs a new object with the given label.
      Parameters:
      label - the label to display
    • Tab

      public Tab(Component... components)
      Constructs a new object with child components.
      Parameters:
      components - the child components
  • Method Details

    • getLabel

      public final String getLabel()
      Gets the label of this tab.
      Specified by:
      getLabel in interface HasLabel
      Returns:
      the label
    • setLabel

      public final void setLabel(String label)
      Sets the label of this tab.
      Specified by:
      setLabel in interface HasLabel
      Parameters:
      label - the label to display
    • setFlexGrow

      public void setFlexGrow(double flexGrow)
      Sets the flex grow property of this tab. 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 tab should take up
    • getFlexGrow

      public double getFlexGrow()
      Gets the flex grow property of this tab.
      Returns:
      the flex grow property, or 0 if none was set
    • setSelected

      public void setSelected(boolean selected)
      If true, the item is in selected state.
      Parameters:
      selected - the boolean value to set
    • isSelected

      public boolean isSelected()
      If true, the item is in selected state.

      This property is not synchronized automatically from the client side, so the returned value may not be the same as in client side.

      If a Tab instance is used inside Tabs component then selected state is updated based on currently selected tab. So the value is the same as Tabs.getSelectedTab().
      Returns:
      the selected property from the webcomponent
      See Also:
    • toString

      public String toString()
      Overrides:
      toString in class Object