Skip to main content

Tabs

The Tabs component is a widget that organizes its child elements into pages, which can be switched between using tab labels along one edge. The tabs can be arranged either vertically or horizontally.

Each tab can contain both text labels and icons, providing flexibility in content presentation. The content of each page can be any existing widget or a customized one.

Properties

The Tabs widget inherits from Widget class → Has all Widget properties.
  • orientation: OrientationTypes → The orientation of the widget.

Constructor

ParameterTypeRequiredDescription
idstringyesThe id of the widget
parentWidgetnoThe parent of the widget. Default is null
orientationOrientationTypesnoThe orientation of the widget. Default is horizontal
src/main.ts
import { Tabs } from "@cedro/ui";

const myTab: Tabs = new Tabs("my-tab");

myTab.addTab("tab-one", "Tab One", contentWidget);
myTab.addIconTab("tab-two", "home", otherContentWidget);

Public Methods

setOrientation

Set the orientation of the widget. Can be horizontal or vertical.

Parameters

ParameterTypeRequiredDescription
orientationOrientationTypesyesThe orientation.

Returns Value

void

Example

src/main.ts
myTab.setOrientation("vertical");

addTab

Add a tab item to the widget with a label header.

Parameters

ParameterTypeRequiredDescription
idstringyesThe id.
titlestringyesThe title of the tab item label.
contentWidgetyesThe content widget for the tab item.
scrollablebooleannoIndicate if the tab content has a scrollbar. Default is false.

Returns Value

void

Example

src/main.ts
myTab.addTab("tab-item-id", "Tab Title", contentWidget, true);

addIconTab

Add a tab item to the widget with an icon header.

Parameters

ParameterTypeRequiredDescription
idstringyesThe id.
iconstringyesThe icon of the tab item label.
contentWidgetyesThe content widget for the tab item.
scrollablebooleannoIndicate if the tab content has a scrollbar. Default is false.

Returns Value

void

Example

src/main.ts
myTab.addIconTab("tab-item-id", "home", contentWidget, true);

setTab

Set the active tab item.

Parameters

ParameterTypeRequiredDescription
idstringyesThe tab item id to activate.

Returns Value

void

Example

src/main.ts
myTab.setTab("tab-item-id");