Side Tabs
WdSideTab
1. Applicable Scenarios
Provides a side tab layout that supports switching between multiple option tabs.

Side tabs with icons, preceding icon:

Side 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.sideTab1.selectedValue
, where sideTab1
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 in the component slot 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.sideTab1.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' }
];
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.
Property Introduction
Properties
组件接收的外部传入的属性
属性名 | 属性标识 | 类型 | 说明 |
---|
标签 | list | array | 设置侧边导航面板各标签的标题 示例:[ { "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" } ] |
选中标签 | selectedValue | string | 选中值可通过表达式$w.sideTab1.selctedValue获取 默认值:"1" |
切换标签展示不同组件 | isMultipleSlot | boolean | 开启后,各标签可展示不同内容区域 示例:false |
Events
组件暴露的事件,可以监听组件的事件来触发一些外部的动作
事件名 | 事件code | 事件出参 event.detail | 适用情况 | 说明 |
---|
点击 | tap | 兼容三端 | - | |
选项卡切换 | change | object
| 兼容三端 | - |
Property API
通过属性 API,可以获取组件内部的状态和属性值,可以通过$w.componentId.propertyName
来访问组件内部的值,如 $w.input1.value
,详请请参考 属性 API
只读属性名 | 属性标识 | 类型 | 说明 |
---|
标签 | list | array | 设置侧边导航面板各标签的标题 |
选中标签 | selectedValue | string | 选中值可通过表达式$w.sideTab1.selctedValue获取 |
切换标签展示不同组件 | isMultipleSlot | boolean | 开启后,各标签可展示不同内容区域 |
Method API
通过方法 API,可以通过程序触发组件内部的方法,比如提交表单,显示弹窗等, 可以通过$w.componentId.methodName
来调用组件方法,如 $w.form1.submit()
方法名 | 方法标识 | 参数 | 方法说明 |
---|
设置选中标签 | selectTab | object
| 设置选中标签 |
Style API
通过样式 API,可以覆盖组件中内部元素的样式来实现自定义,例如在低代码编辑器中中通过 #wd-page-root .wd-btn
即可为所有的按钮组件编写样式,通过 :scope
可以控制单个组件样式, 详细说明请参考样式 API
名称 | 类名 | 说明和示例 |
---|
根元素 | .wd-side-tab-root | 侧边选项卡根元素
|
PC 端侧边选项卡根元素 | .wd-pc-side-tab-root | 可以为 PC 端的侧边选项卡编写样式
|
H5 端侧边选项卡根元素 | .wd-h5-side-tab-root | 可以为 H5 端的侧边选项卡编写样式
|
小程序端侧边选项卡根元素 | .wd-mp-side-tab-root | 可以为小程序端的侧边选项卡编写样式
|
左侧选项区域 | .wd-side-tab-root .wd-tabs__header | 可以为侧边选项卡左侧选项区域编写样式
|
文本标签容器 | .wd-side-tab-root .wd-tabs__item | 可以为侧边选项卡文本标签容器编写样式
|
选中态的标签容器 | .wd-side-tab-root.wd-tabs--vertical .wd-tabs__item.is-selected | 可以为侧边选项卡选中的标签容器编写样式
|
文本标签 | .wd-side-tab-root .wd-tabs__item-text | 可以为侧边选项卡文本标签编写样式
|
选项图标(图片) | .wd-side-tab-root .wd-tabs__item .wd-image | 可以为选项文本标签设置样式
|
选项图标(图标) | .wd-side-tab-root .wd-tabs__item .wd-icon | 可以为选项文本标签设置样式
|
右侧内容区域 | .wd-side-tab-root .wd-tabs__body | 可以为侧边选项卡右侧内容区域编写样式
|
Frequently Asked Questions
Why is there no scroll bar in the mini-program after setting the tab width?
Due to mini-program restrictions, if you need to use a scroll view in the mini-program, you must add a scrolling container. Refer to the Scrolling Container Usage Documentation.