Skip to content

Tabs - Web Component โ€‹

The Tabs component can be used imported from:

Playground โ€‹

Parameters โ€‹

The Web component uses the <z-tabs> tag:

By default, all the parameters are optional or can be set in different, except for the ones marked as required

The parametrization of the component can be done with the following custom HTML params:

NameTypeDescriptionSlotA11y
tabsobject[]Array of tabs.
valuenumberIndex of the active tab.

Events โ€‹

This component has events. Check the documentation about how to use the events.

NamePayloadDescription
changebooleanReturns the new value of the "value" attribute

Slots โ€‹

This component has slots. Check the documentation about how to use the slots.

NameTagsDescription
tab-<number>spanTab content
tab-<number>-labelspanTab label

Parameters use โ€‹

tabs โ€‹

The tabs attribute is an array of objects with the following properties:

  • name (string): The name of the tab.
  • icons (string): The name of the icon shown in the tab.
  • content (string): The content of the tab.

An example:

Also using icons for the tabs:

We can use <option> tags to define the values of tabs:

The tabs content can be HTML if the tab-<index> slots are used. The index starts on 1:

HTML

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

CSS

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

JS

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

There's a third option for defining the tabs. If you're going to directly use the tab- slots for the tabs content, you can set the nameand/or disabled directly on the slot:

HTML

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

CSS

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

JS

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

We can customize the tabs labels'content also using the tab-<index>-label slots:

๐ŸŸฆ HTML ๐ŸŸฆ CSS ๐ŸŸฆ JS
HTML

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

CSS

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

JS

Lorem ipsum dolor sit amet, consectetur adipiscing elit.

value โ€‹

The value attribute is the index of the tab that is currently active. The value start in 1, not 0.

HTML - Lorem ipsum dolor sit amet, consectetur adipiscing elit.
CSS - Lorem ipsum dolor sit amet, consectetur adipiscing elit.
JS - Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Browser support โ€‹

Detected engine: ย 

  • Chromium

  • Webkit

  • Gecko

HTML Examples โ€‹

CodeSandbox example โ€‹