# Tab component

# Code examples

# Basic tab example

# Nested tab

# Leading icon

# Top icon

# Closable tabs

# Tabs with dropdown

# Insert a tab using fragment-configuration

# Dynamically insert a tab using JavaScript

# API

# Tab component template

Template example:

<div class="tabs">
    <gtab group="mytabs" body="tab1" class="stacked" icon-class="fv__icon-comment-item-menu-settings" active>Tab Text 1</gtab>
    <gtab group="mytabs" body="tab2" class="stacked" closable destroy-on-close>Tab Text 2<gtab>
</div>
<div class="tab-bodies">
    <div name="tab1">Tab One</div>
    <div name="tab2">Tab Two</div>
</div>

The tab component template properties:

Property Description Type Default Value Version
group Only one tab can be activated in a group,similar to the radio name string -- 7.4.0
body Tab body's name string -- 7.4.0
closable Define if the tab is closable boolean false 7.4.0
destroy-on-close Whether to destroy tab after the tab is closed. Once the tab is destroyed, the body component will be destructed also.
boolean false 7.4.0
class="stacked" Define the tab's 'icon and text' to be displayed in two lines, otherwise in one line. -- -- 7.4.0

# Tab object properties

Property Description Type
disabled Disabled status boolean
isVisible Visibility status boolean
isActive Activity status boolean
isClosed Closes boolean

# Methods

Method Description Version
disable(): void Disable a tab 7.0.0
enable(): void Make a disabled tab enabled 7.0.0
show(): void Make a hidden tab shown 7.0.0
hide(): void Hide a tab 7.0.0
active(): void Activate a tab 7.0.0
deactive(): void Make a tab inactive 7.0.0
destroy(): void Destroy a tab 7.0.0
close(): void Close a tab. The closed tab will be hidden, and the adjacent tab will be activated 7.4.0
open(): void Make a closed tab shown 7.4.0

# Events

Name Description Sample Version
active Triggered when a tab is activated gtab.on('active', () => {}) 7.0.0
deactive Triggered when a tab is deactivated gtab.on('deactive', () => {}) 7.0.0
close Triggered when a tab is closed gtab.on('close', () => {}) 7.4.0
open Triggered when a tab is opened gtab.on('open', () => {}) 7.4.0