1. Domino UI
  2. Components
  3. Tabs
Top Basic Alignment Closable Colored Content Animation Vertical Docs

Tabs

Represents a UI tab component used within a TabsPanel . Provides functionalities such as activation, deactivation, and closability.

Usage example within a TabsPanel :

 
 TabsPanel panel = new TabsPanel();
 Tab exampleTab = Tab.create("Example");
 panel.appendChild(exampleTab);
 exampleTab.activate();
 exampleTab.setClosable(true);
 

See also :

Examples

Basic tabs Tabs can text, icons, or both.

Tabs alignment Tabs can be aligned left, right or middle.

Closable tabs Tabs can have a close/remove button.

Colored tabs Tabs can have different colors.

Tabs content Tabs can have a custom content container.

Tabs animation Activated/Deactivated tabs can have animations.

Vertical tabs Tabs can be aligned vertically.

API Docs: TabsPanel

Constructors

public void TabsPanel()
Creates a new instance of TabsPanel .

Static methods

public static TabsPanel create()
Factory method to create a new instance of TabsPanel .

Returns:

a new instance of TabsPanel .

Public methods

public TabsPanel insertAt(int index, Tab tab)
Inserts a tab at a specific index.

index

the index to insert the tab.

tab

the tab to be inserted.



Returns:

the current TabsPanel instance.

@throws IndexOutOfBoundsException if the index is out of range.
public TabsPanel appendChild(Tab tab)
Appends a tab to the end of the tabs list.

tab

the tab to be appended.



Returns:

the current TabsPanel instance.

public TabsPanel appendChild(FillItem fillItem)
Appends a fill item (usually a spacer or separator) to the tabs navigation list.

fillItem

the fill item to be appended.



Returns:

the current TabsPanel instance.

public void activateTab(int index)
Activates a tab by its index.

index

the index of the tab to activate.

@throws IndexOutOfBoundsException if the index is out of range.
public HTMLDivElement element()
Check super implementation documentation. Returns the root HTMLDivElement that represents the tabs panel.

Returns:

the root HTMLDivElement of this TabsPanel .

public TabsPanel setTransition(Transition transition)
Sets the transition effect for the tabs panel.

transition

the transition to set.



Returns:

the current TabsPanel instance.

public TabsPanel setContentContainer(Element contentContainer)
Sets the container for the tab contents. Replaces the existing content container with the provided one.

contentContainer

the new content container.



Returns:

the current TabsPanel instance.

public TabsPanel setContentContainer(IsElement<?> contentContainer)
Sets the container for the tab contents using an IsElement . This is a convenience method that calls setContentContainer .

contentContainer

the new content container.



Returns:

the current TabsPanel instance.

public DominoElement<Element> getTabsContent()
Returns the element representing the tabs' content container.

Returns:

the DominoElement for the tabs' content.

public Tab getActiveTab()
Returns the currently active tab of this tabs panel.

Returns:

the currently active Tab .

public List<Tab> getTabs()
Returns a list of all tabs in this tabs panel.

Returns:

a list of Tab elements.

public void closeTab(Tab tab)
Closes a given tab. If the closed tab was active, it will activate the next available tab. If there's no other tab, it will deactivate the given tab and set the active tab to null. After closing, it will notify all registered close handlers.

tab

the Tab to close.

public TabsPanel addCloseHandler(Consumer<Tab> closeHandler)
Adds a close handler to be notified when a tab is closed.

closeHandler

a Consumer to handle the tab close event.



Returns:

the current TabsPanel instance.

public TabsPanel removeCloseHandler(Consumer<Tab> closeHandler)
Removes a previously registered close handler.

closeHandler

the close handler to remove.



Returns:

the current TabsPanel instance.

public TabsPanel addActivationHandler(ActivationHandler activationHandler)
Adds an activation handler to be notified when a tab's activation state changes.

activationHandler

the handler to add.



Returns:

the current TabsPanel instance.

public TabsPanel removeActivationHandler(ActivationHandler activationHandler)
Removes a previously registered activation handler.

activationHandler

the handler to remove.



Returns:

the current TabsPanel instance.

public TabsPanel activateByKey(String key)
Activates a tab by its key.

key

the unique identifier of the tab.



Returns:

the current TabsPanel instance.

public TabsPanel activateByKey(String key, boolean silent)
Activates a tab by its key, with an option to keep the activation silent.

key

the unique identifier of the tab.

silent

whether the activation should be silent.



Returns:

the current TabsPanel instance.

public Optional<Tab> findByKey(String key)
Finds the first tab by the specified key. this is a case-sensitive search

key

The tab key



Returns:

Optional of a tab.

public boolean isAutoActivate()
Checks if the auto-activation feature is enabled. When auto-activation is enabled, the first tab added to the tabs panel will automatically be set as active.

Returns:

true if auto-activation is enabled, false otherwise.

public TabsPanel setAutoActivate(boolean autoActivate)
Sets the auto-activation feature. When auto-activation is enabled, the first tab added to the tabs panel will automatically be set as active.

autoActivate

true to enable auto-activation, false to disable it.



Returns:

the current TabsPanel instance for method chaining.

public TabsPanel setTabsAlign(TabsAlign align)
Configures the tabs' alignment.

align

the desired alignment for the tabs.



Returns:

the current TabsPanel instance.

public TabsPanel setTabsDirection(TabsDirection direction)
Sets the direction for the tabs. This will determine the orientation in which the tabs are displayed within the panel.

direction

the desired TabsDirection for the tabs.



Returns:

the current TabsPanel instance for method chaining.

public TabsPanel setHeaderDirection(HeaderDirection direction)
Sets the direction for the header. This can be used to control the layout orientation of the header section relative to the content.

direction

the desired HeaderDirection for the header.



Returns:

the current TabsPanel instance for method chaining.

public TabsPanel setTabHeaderAlign(TabsHeaderAlign align)
Sets the alignment for the tab headers. This defines the positioning of the headers within the tabs container.

align

the desired TabsHeaderAlign for the tab headers.



Returns:

the current TabsPanel instance for method chaining.

public TabsPanel withTabsNav(ChildHandler<TabsPanel, UListElement> handler)
Apply customizations to the tabs' navigation.

handler

the handler for customizing the tabs' navigation.



Returns:

the current TabsPanel instance.

public UListElement getTabsNav()


Returns:

the tabs UListElement

public TabsPanel withTabsContent(ChildHandler<TabsPanel, DominoElement<Element>> handler)
Apply customizations to the tabs' content.

handler

the handler for customizing the tabs' content.



Returns:

the current TabsPanel instance.

public TabsPanel withMainNav(ChildHandler<TabsPanel, DivElement> handler)
Apply customizations to the tabs main navigation element.

handler

the handler for customizing the tabs' content.



Returns:

the current TabsPanel instance.

public TabsPanel withNavLeadElement(ChildHandler<TabsPanel, DivElement> handler)
Apply customizations to the tabs leading navigation element.

handler

the handler for customizing the tabs' content.



Returns:

the current TabsPanel instance.

public TabsPanel withNavTailElement(ChildHandler<TabsPanel, DivElement> handler)
Apply customizations to the tabs tail navigation element.

handler

the handler for customizing the tabs' content.



Returns:

the current TabsPanel instance.

public TabsPanel withEachTab(ChildHandler<TabsPanel, Tab> handler)
Applies the handler on each tab that is currently present in the TabsPanel

handler

ChildHandler



Returns:

same tabs panel

public DivElement getMainNav()


Returns:

The container that hosts the tabs nav element in addition to navigation leading element and navigation tail element used to implement navigation overflow behavior

public DivElement getLeadingNav()
used to host tabs overflow elements.

Returns:

The navigation leading element to the left of the tabs navigation elements

public DivElement getTailNav()
used to host tabs overflow elements.

Returns:

the navigation tail element to the right of the tabs navigation element.

Constructors

public void Tab(String title)
Constructor to create a tab with a specified title.

title

The title of the tab.

public void Tab(Node title)
Constructor to create a tab with a specified title.

title

The title of the tab.

public void Tab(Icon<?> icon)
Constructor to create a tab with a specified icon.

icon

The icon of the tab.

public void Tab(Icon<?> icon, String title, String key)
Constructor to create a tab with a specified icon, title, and key.

icon

The icon of the tab.

title

The title of the tab.

key

The key associated with the tab.

public void Tab(Icon<?> icon, Node title, String key)
Constructor to create a tab with a specified icon, title, and key.

icon

The icon of the tab.

title

The title of the tab.

key

The key associated with the tab.

public void Tab(Icon<?> icon, String title)
Constructor to create a tab with a specified icon and title.

icon

The icon of the tab.

title

The title of the tab.

public void Tab(Icon<?> icon, Node title)
Constructor to create a tab with a specified icon and title.

icon

The icon of the tab.

title

The title of the tab.

Static methods

public static Tab create(String title)
Factory method to create a tab with a specified title.

title

The title of the tab.



Returns:

The created tab.

public static Tab create(Node title)
Factory method to create a tab with a specified title.

title

The title of the tab.



Returns:

The created tab.

public static Tab create(String key, String title)
Creates a new Tab instance with the specified key and title.

key

The key associated with the tab.

title

The title of the tab.



Returns:

The newly created Tab instance.

See also :

public static Tab create(String key, Node title)
Creates a new Tab instance with the specified key and title.

key

The key associated with the tab.

title

The title of the tab.



Returns:

The newly created Tab instance.

See also :

public static Tab create(Icon<?> icon)
Creates a new Tab instance with the specified icon.

icon

The icon of the tab.



Returns:

The newly created Tab instance.

See also :

public static Tab create(String key, Icon<?> icon)
Creates a new Tab instance with the specified key and icon.

key

The key associated with the tab.

icon

The icon of the tab.



Returns:

The newly created Tab instance.

See also :

public static Tab create(Icon<?> icon, String title)
Creates a new Tab instance with the specified icon and title.

icon

The icon of the tab.

title

The title of the tab.



Returns:

The newly created Tab instance.

See also :

public static Tab create(Icon<?> icon, Node title)
Creates a new Tab instance with the specified icon and title.

icon

The icon of the tab.

title

The title of the tab.



Returns:

The newly created Tab instance.

See also :

public static Tab create(String key, Icon<?> icon, String title)
Creates a new Tab instance with the specified key, icon, and title.

key

The key associated with the tab.

icon

The icon of the tab.

title

The title of the tab.



Returns:

The newly created Tab instance.

See also :

public static Tab create(String key, Icon<?> icon, Node title)
Creates a new Tab instance with the specified key, icon, and title.

key

The key associated with the tab.

icon

The icon of the tab.

title

The title of the tab.



Returns:

The newly created Tab instance.

See also :

Public methods

public HTMLElement getAppendTarget()
Returns the target element where content can be appended.

Returns:

The HTMLElement representing the content area of the tab.

public LIElement getTab()
Returns the underlying LI element of the tab.

Returns:

The LIElement that represents the tab.

public DivElement getTabPanel()
Returns the div element that represents the content area of the tab.

Returns:

The DivElement representing the content area of the tab.

public Tab appendChild(Node content)
Appends a Node to the content area of the tab.

content

The content to be appended.



Returns:

The current Tab instance.

public Tab appendChild(IsElement<?> content)
Appends an IsElement to the content area of the tab.

content

The content to be appended.



Returns:

The current Tab instance.

public Tab setContent(IsElement<?> element)
Sets the content of the tab using an IsElement .

element

The content to be set.



Returns:

The current Tab instance.

public Tab setContent(Node content)
Sets the content of the tab using a Node .

content

The content to be set.



Returns:

The current Tab instance.

public Tab setTitle(String title)
Sets the title of the tab.

title

The title to be set.



Returns:

The current Tab instance.

public Tab setTitle(Node title)
Sets the title of the tab.

title

The title to be set.



Returns:

The current Tab instance.

public Tab setIcon(Icon<?> icon)
Sets the icon of the tab.

icon

The icon to be set.



Returns:

The current Tab instance.

public Tab activate()
Activates the tab.

Returns:

The current Tab instance.

public Tab activate(boolean silent)
Activates the tab with an option to silence activation events.

silent

If true, the activation event handlers will not be triggered.



Returns:

The current Tab instance.

public Tab deActivate()
Deactivates the tab.

Returns:

The current Tab instance.

public Tab deActivate(boolean silent)
Deactivates the tab with an option to silence deactivation events.

silent

If true, the deactivation event handlers will not be triggered.



Returns:

The current Tab instance.

public Tab setClosable(boolean closable)
Sets the tab's closability status.

closable

If true, the tab becomes closable; otherwise, it's not closable.



Returns:

The current Tab instance.

public Tab close()
Closes the tab.

Returns:

The current Tab instance.

public Tab closable()
Makes the tab closable.

Returns:

The current Tab instance.

public Tab notClosable()
Makes the tab non-closable.

Returns:

The current Tab instance.

public Tab setOnBeforeCloseHandler(CloseHandler closeHandler)
Sets a handler that is triggered before the tab is closed.

closeHandler

The CloseHandler instance that provides the close condition.



Returns:

The current Tab instance.

public Tab addCloseHandler(Consumer<Tab> closeHandler)
Adds a close handler that will be triggered when the tab is closed.

closeHandler

The close handler to be added.



Returns:

The current Tab instance.

public Tab removeCloseHandler(Consumer<Tab> closeHandler)
Removes a previously added close handler.

closeHandler

The close handler to be removed.



Returns:

The current Tab instance.

public Tab addActivationHandler(ActivationHandler activationHandler)
Adds an activation handler that will be triggered when the tab is activated or deactivated.

activationHandler

The activation handler to be added.



Returns:

The current Tab instance.

public Tab removeActivationHandler(ActivationHandler activationHandler)
Removes a previously added activation handler.

activationHandler

The activation handler to be removed.



Returns:

The current Tab instance.

public boolean isActive()
Checks if the tab is currently active.

Returns:

True if the tab is active, otherwise false.

public HTMLAnchorElement getClickableElement()
Retrieves the clickable anchor element of the tab.

Returns:

The HTMLAnchorElement which is the clickable element of the tab.

public HTMLLIElement element()
Retrieves the main LI element that represents the tab.

Returns:

The HTMLLIElement which represents the tab.

public String getKey()
Retrieves the unique key associated with the tab.

Returns:

The key of the tab.

public Tab setKey(String key)
Sets the unique key for the tab.

key

The unique key to set.



Returns:

The current Tab instance.

public void removeTab()
Removes the tab and its associated panel content.
public Tab withHeader(ChildHandler<Tab, DivElement> handler)
Adds child elements to the header of the tab using the provided handler.

handler

The ChildHandler which defines how child elements should be added to the tab's header.



Returns:

The current Tab instance.

public Tab withContent(ChildHandler<Tab, DivElement> handler)
Adds child elements to the content of the tab using the provided handler.

handler

The ChildHandler which defines how child elements should be added to the tab's content panel.



Returns:

The current Tab instance.

We are a group of passionate people who love what we do

Donate & Support Us