Skip to main content
4.0.7Next5.1.05.0.35.0.25.0.15.0.04.0.94.0.84.0.73.2.03.1.03.0.13.0.02.1.12.0.101.0.0
Version: 4.0.7

Tab

Tabs are a navigation tool which splits content into pages, allowing users to select which page they want to see. This can be useful, both to contain completely different parts of the UI, or to simply display different versions of a minor UI element.

Basic Usage

<triton-tab>
<triton-tab-item tab-title="Tab 1"> The content of tab 1 </triton-tab-item>
<triton-tab-item tab-title="Tab 2" active> The content of tab 2 </triton-tab-item>
<triton-tab-item tab-title="Tab 3" disabled> The content of tab 3 </triton-tab-item>
</triton-tab>
<TritonTab>
<TritonTabItem tab-title="Tab 1"> The content of tab 1 </TritonTabItem>
<TritonTabItem tab-title="Tab 2" active> The content of tab 2 </TritonTabItem>
<TritonTabItem tab-title="Tab 3" disabled> The content of tab 3 </TritonTabItem>
</TritonTab>
<html> 
<head>
<script type="module">
import { defineCustomElements } from '~node_modules/@kognifai/triton-cl-core/loader/index.es2017.js';
defineCustomElements();
</script>
</head>
<body>
<TritonTab>
<TritonTabItem tab-title="Tab 1"> The content of tab 1 </TritonTabItem>
<TritonTabItem tab-title="Tab 2" active> The content of tab 2 </TritonTabItem>
<TritonTabItem tab-title="Tab 3" disabled> The content of tab 3 </TritonTabItem>
</TritonTab>
</body>
</html>
The content of tab 1 The content of tab 2 The content of tab 3

Variants

The default tab is horizontal, as seen in the basic example.

Vertical Tabs

Tabs can also be set up to fall vertically, as opposed to their default horizontal orientation. To achieve this, set the orientation property to vertical.

The content of tab 1The content of tab 2The content of tab 3
<triton-tab orientation="vertical">
<triton-tab-item tab-title="Tab 1">The content of tab 1</triton-tab-item>
<triton-tab-item tab-title="Tab 2">The content of tab 2</triton-tab-item>
<triton-tab-item tab-title="Tab 3">The content of tab 3</triton-tab-item>
</triton-tab>

Behavior

To use the tab component as a menu, pass in the component without any content. The router implementation depends on your framework. For Angular, use the RouterModule and apply routerLinkActive and routerLink on the TritonTabItem element. With routerLinkActive set to active, the component will trigger the correct state on the selected tab item.

The content of tab 1The content of tab 2The content of tab 3The content of tab 4
<triton-tab>
<triton-tab-item tab-title="Orders" icon-leading="broadcast">The content of tab 1</triton-tab-item>
<triton-tab-item tab-title="Details" icon-leading="box" active>The content of tab 2</triton-tab-item>
<triton-tab-item tab-title="Report" icon-leading="chat-buble">The content of tab 3</triton-tab-item>
<triton-tab-item tab-title="Critical" icon-leading="cancel">The content of tab 4</triton-tab-item>
</triton-tab>

Appearance

Fluid Width

By setting the fluid property to true, you can force the TritonTab to fill the full width of its container.

The content of tab 1The content of tab 2The content of tab 3
<triton-tab fluid="true">
<triton-tab-item tab-title="Tab 1">The content of tab 1</triton-tab-item>
<triton-tab-item tab-title="Tab 2">The content of tab 2</triton-tab-item>
<triton-tab-item tab-title="Tab 3">The content of tab 3</triton-tab-item>
</triton-tab>

Custom tab header

The usage of a custom tab header should be limited to situations where there is a specific requirement for custom elements in the tab item header. To append the current element to the header, you can easily achieve this by adding the slot="tab-item-header" attribute to any element within the triton-tab-item.

Custom Text
The content of tab 1
<triton-tab>

<triton-tab-item>
<div slot="tab-item-header">
Custom Text
</div>
</triton-tab-item>

<triton-tab-item tab-title="Tab 2">
The content of tab 1
</triton-tab-item>

</triton-tab>

In addition, you can utilize the tab-title element along with the slot="tab-item-header" to render the slot content before the title in the tab header. This allows for further customization and flexibility in designing the tab item header.

It's important to note that the usage of tab-title with slot="tab-item-header" should be approached with caution and only employed when necessary. It is not the recommended way to use triton-tab-item and should be reserved for specific cases that require this level of customization.

Size

The following sizes are available in the Triton Design System.

small size tab 1small size tab 2small size tab 3small size tab 4small size tab 5small size tab 6base size tab 1base size tab 2base size tab 3base size tab 4base size tab 5base size tab 6
<triton-tab size="small">
<triton-tab-item tab-title="Tab 1">small size tab 1</triton-tab-item>
...
</triton-tab>

<triton-tab size="base">
<triton-tab-item tab-title="Tab 1">base size tab 1</triton-tab-item>
...
</triton-tab>

Playground

API

Properties

TritonTab

PropertyDescriptionTypeDefault
fluidIf true, the element fills all available widthbooleanfalse
orientationSet the orientation of the tabs. If set to vertical the tabs will group downwardsNote The fluid property is not compatible with vertical orientationhorizontal vertical'horizontal'
sizeSet the size of the componentbase body large medium small tiny xlarge xxlarge xxxlarge'base'

TritonTabItem

PropertyDescriptionTypeDefault
activeThe tab that is currently openbooleanfalse
disabledIf true, the component will look disabled and not be interactableboolean-
fluidIf true, the element fills as much width as it canboolean-
icon-leadingIcon displayed on the left of the tabs titleIcon-
icon-trailingIcon displayed on the right of the tabs titleIcon-
notification-countDisplay number of new notifications on the tabnumber-
sizeSet the size of the tab in the tab barbase body large medium small tiny xlarge xxlarge xxxlarge'body'
tab-titleThe title to be displayed on the tabstring-

Slots

Main

can only be a TritonTabItem, any other element will be ignored

<triton-tab>
<div></div>
</triton-tab>

Details

Depends on