Tabs

Switch between panels containing related content.

Live preview
Interact with the component to see results here.
View code
HTML
<sy-tab-group
  active="0"
  type="line"
  position="top"
  size="medium"
  align="left"
  padding="none"
  id="sample"
  style="width:100%;height:250px"
>
  <sy-tab tabkey="tab-0">Overview</sy-tab>
  <sy-tab tabkey="tab-1">Activity</sy-tab>
  <sy-tab tabkey="tab-2">Settings</sy-tab>
  <sy-tab-content name="tab-0">
    <p style="margin:20px 0">View project status at a glance.</p>
  </sy-tab-content>
  <sy-tab-content name="tab-1">
    <p style="margin:20px 0">Review recent changes and team activity.</p>
  </sy-tab-content>
  <sy-tab-content name="tab-2">
    <p style="margin:20px 0">Manage the project's basic settings.</p>
  </sy-tab-content>
</sy-tab-group>

Usage guide

#

Separate and switch related content within one context. Use Navigation across the app and Steps for sequential tasks.

  1. Pair tabs with content

    Match sy-tab's tabkey to sy-tab-content's name.

  2. Set the active tab

    active starts at 0. Use setActiveTab() to switch in code.

  3. Many tabs or closable tabs

    Use the overflow menu to navigate many tabs. Set closable only on tabs that need a close action.

Feature examples

#

Choose a feature from 24 topics. Explore property settings, method calls, event results, and slot layouts through live examples and code.

Usage examples · Content Overview

Try the selected example. Topics with multiple configurations let you switch between detailed examples.

View code
HTML
Loading the example.

Usage examples · Overview

Try the selected example. Topics with multiple configurations let you switch between detailed examples.

View code
HTML
Loading the example.

Usage examples · Item Overview

Try the selected example. Topics with multiple configurations let you switch between detailed examples.

View code
HTML
Loading the example.

Property · Active

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Align

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Disabled

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Draggable

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Item Attributes / Active

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Item Attributes / Closable

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Item Attributes / Disabled

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Item Attributes / Manual Close

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Item Attributes / Tabkey

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Padding

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Position

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Size

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Property · Type

See how settings change appearance and behavior.

View code
HTML
Loading the example.

Methods · CloseTab

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Methods · Item Methods / SetClose

Use the example's buttons to call methods and inspect their results.

View code
HTML
Loading the example.

Events · Closed

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Events · Item Events / Closed

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Events · Item Events / Selected

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Events · Ordered

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Events · Selected

Interact with the component to see event names and payloads in the live preview below.

View code
HTML
Loading the example.

Usage examples · Bottom tab navigation

Place centered tabs below their content panel.

View code
HTML
<sy-tab-group
  active="0"
  type="line"
  position="bottom"
  size="medium"
  align="center"
  padding="none"
  id="sample"
  style="width:100%;height:250px"
>
  <sy-tab tabkey="tab-0">Overview</sy-tab>
  <sy-tab tabkey="tab-1">Activity</sy-tab>
  <sy-tab tabkey="tab-2">Settings</sy-tab>
  <sy-tab-content name="tab-0">
    <p style="margin:20px 0">View project status at a glance.</p>
  </sy-tab-content>
  <sy-tab-content name="tab-1">
    <p style="margin:20px 0">Review recent changes and team activity.</p>
  </sy-tab-content>
  <sy-tab-content name="tab-2">
    <p style="margin:20px 0">Manage the project's basic settings.</p>
  </sy-tab-content>
</sy-tab-group>

<script type="module">
  const component1 = document.querySelector("#sample");
  Object.assign(component1, {
    "position": "bottom",
    "align": "center"
  });
</script>

API reference

#

Hover over a name or focus it with the keyboard to see the code. On touch screens, tap the name.

<sy-tab-group>

Properties

Attribute / PropertyTypeDefaultDescription
numberundefinedCurrent tab index, starting at 0.
'center' | 'left''left'Left or center alignment of the tab row.
booleanfalseBlock user interaction and keyboard focus.
booleanfalseAllow tabs to be reordered by dragging.
"top" | "bottom" | "left" | "right""top"Item layout direction.
"card" | "line""line"line or card style.
"small" | "medium" | "large""medium"Component size.
"small" | "medium" | "large" | 'none'"none"Padding inside the tab area.
booleanfalseProvide an add button and the tabAdded event. The app creates the new tab.

Events

EventDetailDescription
CustomEvent<any>Emitted when the user selects an item.
CustomEvent<any>Read the result from the event's detail.
CustomEvent<HTMLSyTabElement[]>Read the result from the event's detail.
CustomEvent<{ index: number; value: string }>Read the result from the event's detail.
CustomEvent<{ index: number; value: string }>Read the result from the event's detail.
CustomEvent<void>Read the result from the event's detail.

Methods

MethodReturnsDescription
Promise<void>Remove a tab and its associated content by index or tabkey.
Promise<void>Select a tab by its zero-based index.
Promise<number | undefined>Return the current tab index, or undefined if no tab is selected.

Slots

SlotDescription
Content displayed in the tabs area.
Content displayed in the extra area.
Component body or child items.
Content displayed in the contents area.

<sy-tab>

Properties

Attribute / PropertyTypeDefaultDescription
booleanfalseShow the close button.
booleanfalseBlock user interaction and keyboard focus.
stringundefinedUnique tab key associated with the content's name.
booleanfalseEmit only a close request. After confirmation, call closeTab on the parent.
booleanfalseCurrently selected tab. Managed by the parent.
booleanfalseDisabled state passed down by the parent.
booleanfalseFinal disabled state combining the parent and individual settings.
numberundefinedItem index calculated by the parent.
"card" | "line""line"line or card style, passed down by the parent.
"small" | "medium" | "large""medium"Component size.
"top" | "bottom" | "left" | "right""top"Item layout direction.
booleanfalseTab styling inside Global Header, set by the header.

Events

EventDetailDescription
CustomEvent<any>Emitted when the user selects an item.
CustomEvent<any>Read the result from the event's detail.

Methods

MethodReturnsDescription
Promise<void>Close the item.

Slots

SlotDescription
Component body or child items.

<sy-tab-content>

Properties

Attribute / PropertyTypeDefaultDescription
booleanfalseWhether the content associated with the current tab is visible. Managed by the parent.
booleanfalseBlock user interaction and keyboard focus.
stringundefinedUse the same value as the tabkey of the sy-tab to display.

Slots

SlotDescription
Component body or child items.