tabs
tabs lets users switch between associated content areas without containing the content itself.
XML Element |
|
|---|---|
Java Class |
|
Basics
By default, tabs are displayed in a horizontal row, with the tab labels arranged one after another. This row of tabs is typically positioned at the top or bottom of the associated content area.
The following example demonstrates basic tabs functionality.
<tabs width="100%">
<tab id="issueTab" label="Issues"/>
<tab id="featureTab" label="Features"/>
<tab id="bugTab" label="Bugs"/>
</tabs>
In this example, the component contains two nested tab elements. To update the content associated with the selected tab, define an event handler that listens for the SelectedChangeEvent. When a tab is selected, this event is fired, allowing you to update the displayed content accordingly.
Orientation
While horizontal orientation is default, vertical orientation can be alternative option in certain scenarios. For example, with a larger number of tabs, this orientation may provide additional space for their labels.
Use the orientation attribute to change the orientation of tabs.
<checkbox id="orientationCheckbox" label="Vertical"/>
<tabs id="tabs" width="100%">
<tab id="profileTab">
<icon icon="USER"/>
<span text="Profile"/>
</tab>
<tab id="notificationsTab">
<icon icon="BELL"/>
<span text="Notifications"/>
</tab>
<tab id="settingsTab">
<icon icon="COG"/>
<span text="Settings"/>
</tab>
</tabs>
@ViewComponent
protected Tabs tabs;
@Subscribe("orientationCheckbox")
protected void onOrientationCheckboxValueChane(ComponentValueChangeEvent<JmixCheckbox, Boolean> event) {
tabs.setOrientation(event.getValue() ? Tabs.Orientation.VERTICAL : Tabs.Orientation.HORIZONTAL);
}
States
A tab can be selected, unselected, or disabled:
These states allow users to easily determine which tab is currently active and which tabs may be temporarily unavailable or disabled.
<tabs id="tabs" width="100%">
<tab id="tab1" label="Selected"/>
<tab id="tab2" label="Unselected"/>
<tab id="tab3" label="Disabled" enabled="false"/>
</tabs>
@Subscribe("tabs")
protected void onTabsSelectChangeEvent(Tabs.SelectedChangeEvent event) {
event.getPreviousTab().setLabel("Unselected");
event.getSelectedTab().setLabel("Selected");
}
Labels
Individual tabs can nest almost any components within them. This allows you to compose visually distinctive tab labels:
<tabs id="tabs" width="100%">
<tab id="profileTab">
<icon icon="USER"/>
<span text="Profile"/>
</tab>
<tab id="notificationsTab">
<icon icon="BELL"/>
<span text="Notifications"/>
</tab>
<tab id="settingsTab">
<icon icon="COG"/>
<span text="Settings"/>
</tab>
</tabs>
Theme Variants
Use the themeNames attribute to apply one or more theme variants.
| Variant | Description | Supported By |
|---|---|---|
|
Applies to an individual |
Lumo |
|
Centers the tabs within the container. |
Lumo |
|
Makes the tabs smaller. |
Aura, Lumo |
|
Reduces the visual style to emphasize labels only. |
Lumo |
|
Hides the scroll buttons used to navigate overflown tabs. |
Aura, Lumo |
|
Allocates equal width to all tabs and disables scrolling. |
Lumo |
Handlers
The following handlers are specific to tabs:
| Name | Description |
|---|---|
|
The following shared handlers are supported by tabs:
Elements
|
To add an element in Jmix Studio, select the component in the view descriptor XML or in the Jmix UI structure panel and click on the Add button in the Component Inspector panel. |
tab
Individual tabs are defined with nested tab elements.
tab attributesid - ariaLabel - ariaLabelledBy - classNames - colspan - css - enabled - flexGrow - label - themeNames - visible
tab handlers