public class Tabs extends GeneratedVaadinTabs<Tabs> implements com.vaadin.flow.component.HasOrderedComponents<Tabs>, com.vaadin.flow.component.HasSize
vaadin-tabs element.
Tab components can be added to this component with the
add(Tab...) method or the Tabs(Tab...) constructor. The Tab
components added to it can be selected with the
setSelectedIndex(int) or setSelectedTab(Tab) methods.
Removing the selected tab from the component changes the selection to the
next available tab.
Note: Adding or removing Tab components via the Element API,
eg. tabs.getElement().insertChild(0, tab.getElement()); , doesn't
update the selected index, so it may cause the selected tab to change
unexpectedly.
| Modifier and Type | Class and Description |
|---|---|
static class |
Tabs.Orientation
The valid orientations of
Tabs instances. |
static class |
Tabs.SelectedChangeEvent
An event to mark that the selected tab has changed.
|
| Constructor and Description |
|---|
Tabs()
Constructs an empty new object with
HORIZONTAL orientation. |
Tabs(Tab... tabs)
Constructs a new object enclosing the given tabs, with
HORIZONTAL orientation. |
| Modifier and Type | Method and Description |
|---|---|
void |
add(com.vaadin.flow.component.Component... components) |
void |
add(Tab... tabs)
Adds the given tabs to the component.
|
void |
addComponentAtIndex(int index,
com.vaadin.flow.component.Component component) |
com.vaadin.flow.shared.Registration |
addSelectedChangeListener(com.vaadin.flow.component.ComponentEventListener<Tabs.SelectedChangeEvent> listener)
Adds a listener for
Tabs.SelectedChangeEvent. |
Tabs.Orientation |
getOrientation()
Gets the orientation of this tab sheet.
|
int |
getSelectedIndex()
Gets the zero-based index of the currently selected tab.
|
Tab |
getSelectedTab()
Gets the currently selected tab.
|
protected void |
onAttach(com.vaadin.flow.component.AttachEvent attachEvent) |
void |
remove(com.vaadin.flow.component.Component... components) |
void |
removeAll() |
void |
replace(com.vaadin.flow.component.Component oldComponent,
com.vaadin.flow.component.Component newComponent) |
void |
setFlexGrowForEnclosedTabs(double flexGrow)
Sets the flex grow property of all enclosed tabs.
|
void |
setOrientation(Tabs.Orientation orientation)
Sets the orientation of this tab sheet.
|
void |
setSelectedIndex(int selectedIndex)
Selects a tab based on its zero-based index.
|
void |
setSelectedTab(Tab selectedTab)
Selects the given tab.
|
addThemeVariants, focus, removeThemeVariantsaddListener, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getLocale, getParent, getTranslation, getTranslation, getUI, hasListener, isTemplateMapped, isVisible, onDetach, onEnabledStateChanged, set, setElement, setId, setVisibleclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetComponentAt, getComponentCount, indexOfgetHeight, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getWidth, setHeight, setHeightFull, setMaxHeight, setMaxWidth, setMinHeight, setMinWidth, setSizeFull, setSizeUndefined, setWidth, setWidthFulladdClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassNamepublic Tabs()
HORIZONTAL orientation.public Tabs(Tab... tabs)
HORIZONTAL orientation.tabs - the tabs to enclosepublic void add(Tab... tabs)
tabs - the tabs to enclosepublic void add(com.vaadin.flow.component.Component... components)
add in interface com.vaadin.flow.component.HasComponentspublic void remove(com.vaadin.flow.component.Component... components)
Removing components before the selected tab will decrease the
selected index to avoid changing the selected
tab. Removing the selected tab will select the next available tab.
remove in interface com.vaadin.flow.component.HasComponentspublic void removeAll()
This will reset the selected index to zero.
removeAll in interface com.vaadin.flow.component.HasComponentspublic void addComponentAtIndex(int index,
com.vaadin.flow.component.Component component)
Adding a component before the currently selected tab will increment the
selected index to avoid changing the selected
tab.
addComponentAtIndex in interface com.vaadin.flow.component.HasComponentspublic void replace(com.vaadin.flow.component.Component oldComponent,
com.vaadin.flow.component.Component newComponent)
Replacing the currently selected tab will make the new tab selected.
replace in interface com.vaadin.flow.component.HasOrderedComponents<Tabs>protected void onAttach(com.vaadin.flow.component.AttachEvent attachEvent)
onAttach in class com.vaadin.flow.component.Componentpublic com.vaadin.flow.shared.Registration addSelectedChangeListener(com.vaadin.flow.component.ComponentEventListener<Tabs.SelectedChangeEvent> listener)
Tabs.SelectedChangeEvent.listener - the listener to add, not null@Synchronize(property="selected",
value="selected-changed")
public int getSelectedIndex()
public void setSelectedIndex(int selectedIndex)
selectedIndex - the zero-based index of the selected tab, -1 to unselect allpublic Tab getSelectedTab()
null if none is selectedpublic void setSelectedTab(Tab selectedTab)
selectedTab - the tab to select, null to unselect allIllegalArgumentException - if selectedTab is not a child of this componentpublic Tabs.Orientation getOrientation()
public void setOrientation(Tabs.Orientation orientation)
orientation - the orientationpublic void setFlexGrowForEnclosedTabs(double flexGrow)
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.
flexGrow - the proportion of the available space the enclosed tabs should
take upIllegalArgumentException - if flexGrow is negativeCopyright © 2019 Vaadin Ltd. All rights reserved.