Top Tabs
WdTopTab
1. Applicable Scenarios
Provides a top tab layout that supports switching between multiple option tabs.

Top tabs with icons, preceding icon:

Top tabs with icons, icon after:

2. Basic Capabilities Description
2.1 Label List Configuration
Configure the displayed name and label value directly via the [label] property. Note: Label values must be unique.

If you need to configure dynamic labels, view the configuration Dynamic Label List
2.2 Get Selected Label Value
You can retrieve the selected label value via $w.topTab1.selectedValue, where topTab1 is the component ID. View the current selected value as shown in the figure below:

Example: Dynamically filter and display different data in the list when switching tab labels
As shown in the figure below, we want to filter and display the following "Order" data table separately by "Status". The expected results are as follows:
- Pending

- Processed

Below we will see how to achieve the above results.
- First, create a new data model and add test data, as shown in the figure below:


Select the side tab component and disable the "Switch tabs to display different components" property

In the "Label List" property, set the label list. Note: Label values will be used as query input parameters and must match the values in the data source.

Place a data list below the component and bind the required data source.

Set it as the filter condition for the data list, and retrieve the currently selected label value via
$w.topTab1.selectedValue.

When switching tabs, the corresponding "label value" will be used as a query input parameter to achieve dynamic data filtering.
2.3 Implement the side navigation effect by enabling the "Switch tabs to display different components" property
In a single page, how to achieve the side navigation effect by switching tabs to display different components. Take the following text as an example:
- Enable the "Switch tabs to display different components" property, as shown in the figure below:

- After enabling it, several content slots will be added to the outline tree, each corresponding to a different tab, as shown below:

- Add different components to the content slot as needed, as shown in the figure below with a text component and an image component added respectively:

As can be seen, when switching tabs, different tabs display different component content.
- Label 1

- Label 2

Similarly, you can add more components to the content slots of other tabs.
2.4 Dynamic Label List Configuration
When tab items are dynamic data retrieved from the database, dynamic expressions need to be bound, as shown in the figure below.

Here the required data format is:
[
{ label: 'Label 1', value: '1' },
{ label: 'Label 2', value: '2' },
{ label: 'Label 3', value: '3' },
];
Example: Dynamically generate tab labels using data model data
The tab items in the side tabs are dynamically retrieved from the data model. The expected effect is as follows:

Create a data model and add a new 'Status Name' field.

Enter sample values for several statuses in this model, such as: Pending, To Be Shipped, Shipped

Create a query named query1, select the newly created model for the data table. Trigger method: [Automatic], Method: [Query multiple records]. Run to view the results and save, as shown in the figure below:

Disable the "Switch tabs to display different components" property of the component

Click Bind Variable, bind the query result of query1
$w.query1.data.records, and convert the format to label and value.
$w.query1.data.records.map((item) => ({ label: item.ztmc, value: item.ztmc }));
where ztmc is the status field in the model

- Set [Default Label] as Text

You can see that the tab labels display the pre-entered data from the data model.
Properties
External properties received by the component
Property Name | Property Identifier | Type | Description |
|---|
| Tag. | list | array | Set the title of each tag in the top navigation panel Example: [ { "label": "标签1", "value": "1", "iconType": "none", "innerIcon": "", "outerImage": "", "iconPosition": "prefix", "isDisabled": false, "slotKey": "1" }, { "label": "标签2", "value": "2", "iconType": "none", "innerIcon": "", "outerImage": "", "iconPosition": "prefix", "isDisabled": false, "slotKey": "2" }, { "label": "标签3", "value": "3", "iconType": "none", "innerIcon": "", "outerImage": "", "iconPosition": "prefix", "isDisabled": false, "slotKey": "3" } ] |
| Selected tag | selectedValue | string | The selected value can be obtained using the expression $w.topTab1.selectedValue Default value: "1" |
| Switch tags to show different components | isMultipleSlot | boolean | When enabled, each tag can show different content areas Example: false |
Events
Events exposed by the component. You can listen to component events to trigger external actions
Event Name | Event Code | Event Output Parameters event.detail | Applicable Scenarios | Description |
|---|
| click | tap | Compatible with all platforms | - | |
| Tab switchover | change | object
| Compatible with all platforms | - |
Property API
Through the Property API, you can access the internal state and property values of components. You can access internal values using$w.componentId.propertyName, such as $w.input1.value. For details, please refer to Property API
Read-only Property Name | Property Identifier | Type | Description |
|---|
| Tag. | list | array | Set the title of each tag in the top navigation panel |
| Selected tag | selectedValue | string | The selected value can be obtained using the expression $w.topTab1.selectedValue |
| Switch tags to show different components | isMultipleSlot | boolean | When enabled, each tag can show different content areas |
Method API
Through the Method API, you can programmatically trigger internal methods of components, such as submitting forms, displaying popups, etc. You can call component methods using $w.componentId.methodName, such as $w.form1.submit()
Method Name | Method Identifier | Parameters | Method Description |
|---|
| Set selected tags | selectTab | object
| Set selected tags |
Style API
Through the Style API, you can override the styles of internal elements in components to achieve customization. For example, in the low-code editor, you can write styles for all button components using #wd-page-root .wd-btn, and control individual component styles with :scope. For detailed instructions, please refer toStyle API
Name | Class Name | Description and Examples |
|---|
| root element | .wd-top-tab-root | top tab root element |
| PC-side top tab root element | .wd-pc-top-tab-root | Write styles for the top tab on PC |
| Top tab root element on H5 | .wd-h5-top-tab-root | Write style for H5 top tab |
| WeChat Mini Program top tab root element | .wd-mp-top-tab-root | Can write style for top tab in mini program |
| Top options area | .wd-top-tab-root .wd-tabs__header | Write styles for the top tab option area |
| Tag container | .wd-top-tab-root .wd-tabs__item | Write styles for the text tag container in the top tab |
| Tag container in selected status | .wd-top-tab-root .wd-tabs__item.is-selected | Write styles for the selected tag container in the top tab |
| Text label. | .wd-top-tab-root .wd-tabs__item-text | Can write styles for the top tab text tag |
| Option icon (image) | .wd-top-tab-root .wd-tabs__item .wd-image | Set styles for option text tags |
| Option icon | .wd-top-tab-root .wd-tabs__item .wd-icon | Set styles for option text tags |
| content area | .wd-top-tab-root .wd-tabs__body | You can write styles for the top tab content area, such as setting the top tab content area height to fill the webpage. |
| Overly long tab auto-sliding mask | .wd-tabs-h5-root .wd-tabs__header-item-mask | Set swipe background color for mobile terminal tabs. Note: Slide if tab content is overly long. |