Skip to main content

Tab Bar

WdTabBar

Applicable Scenarios

Used to implement Tab bar navigation effects on pages.

Basic Capabilities Description

  1. In the tab list properties, selecting a single tab allows configuration of attributes such as tab title, icon style, and redirect page. Supports setting independent menus for PC and mobile ends. The selected effect is determined by the page properties in the tab and automatically matched.

Extended Scenarios Description

The Tab bar component is fixed to the bottom of the page and reused across multiple pages.

  1. Click "Layout Design" in the upper-left corner of the editor to access the application layout.
  2. Click "New Layout" to select "Tab Bar Navigation Layout" and create a Tab bar application layout.
  3. Return to "Page Design", select the page node in the outline tree, and set the "Page Layout" to "Tab Bar Navigation Layout" in the page properties area to complete the fixation to the bottom of the page.
  4. You can select other pages and set the "Page Layout" to "Tab Bar Navigation Layout" in the page properties area to reuse it.

Example

Interactive Preview

Property Introduction

External properties received by the component

Property Name
Property Identifier
Type
Description
标签列表tabsobject

标签列表

Example: { "isMultiTerminal": false, "menuData": [ { "title": "标签1", "key": "1", "iconUrl": "td:home" }, { "title": "标签2", "iconUrl": "td:app", "key": "2" }, { "title": "标签3", "iconUrl": "td:user", "key": "3" } ], "mobileMenuData": [] }

路由方式routeTypestring

路由跳转方式,当启用路由时生效

Example: "redirectTo"

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
点击tapobject
  • tab: object

    当前点击的标签

    • title: string名称
    • key: stringkey值
    • iconUrl: string图标
    • iconPath: string自定义未选中图标
    • selectedIconPath: string自定义选中图标
    • disabled: boolean禁用菜单
    • visible: boolean显示菜单
    • type: string链接类型 Optional values:link(外部链接) route(内部链接)
    • path: string跳转内部链接
    • linkUrl: string跳转外部链接
    • linkTargetBlank: boolean跳转开启新窗口
    • subPackageName: string子包名称
Compatible with all platforms

-

选项卡切换changeobject
  • tab: object

    当前选中标签

    • title: string名称
    • key: stringkey值
    • iconUrl: string图标
    • iconPath: string自定义未选中图标
    • selectedIconPath: string自定义选中图标
    • disabled: boolean禁用菜单
    • visible: boolean显示菜单
    • type: string链接类型 Optional values:link(外部链接) route(内部链接)
    • path: string跳转内部链接
    • linkUrl: string跳转外部链接
    • linkTargetBlank: boolean跳转开启新窗口
    • subPackageName: string子包名称
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
标签列表tabsarray
选中标签selectedTabobject

当前选中标签

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
设置选中标签setSelectTabobject
  • key: string选中标签的Key值
  • isNavigate: boolean是否跳转菜单链接 Default value:

设置选中标签

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
根元素.wd-tabbar组件根元素
/* :scope refers to the current component element */
/* For details, refer to the Style API documentation */
:scope.wd-tabbar {
  /* Write CSS styles here */
}
PC 端根元素.wd-pc-tabbar可以为 PC 端的编写样式
/* :scope refers to the current component element */
/* For details, refer to the Style API documentation */
:scope.wd-pc-tabbar {
  /* Write CSS styles here */
}
H5 端根元素.wd-h5-tabbar可以为 H5 端的编写样式
/* :scope refers to the current component element */
/* For details, refer to the Style API documentation */
:scope.wd-h5-tabbar {
  /* Write CSS styles here */
}
小程序 端根元素.wd-mp-tabbar可以为 小程序 端的编写样式
/* :scope refers to the current component element */
/* For details, refer to the Style API documentation */
:scope.wd-mp-tabbar {
  /* Write CSS styles here */
}
文本标签容器.wd-tabbar__item可以为选项区设置样式
:scope .wd-tabbar__item {
        /* 在这里编写CSS 样式*/
color: red;
font-size: 20px;
      } 
选中态的标签容器.wd-tabbar__item.is-selected可以为选中选项区域设置样式
:scope .wd-tabbar__item.is-selected {
        /* 在这里编写CSS 样式*/
color: yellow;
font-size: 20px;
      } 
选项文本标签.wd-tabbar__item-text可以为选项文本标签设置样式
:scope .wd-tabbar__item-text {
        /* 在这里编写CSS 样式 */
font-size: 20px;
      } 
选项图标(图片).wd-tabbar__item .wd-image可以为选项文本标签设置样式
:scope .wd-tabbar__item .wd-image {
        /* 在这里编写CSS 样式 */
width: 20px;
height: 20px;
      } 
选项图标(图标).wd-tabbar__item .wd-icon可以为选项文本标签设置样式
:scope .wd-tabbar__item .wd-icon {
        /* 在这里编写CSS 样式 */
font-size: 20px;
color: red;
      } 

Learn about Style API

Frequently Asked Questions

How to set the text color in the selected state of the Tab bar?

In the Tab bar, the Style API can be used in conjunction to customize the text color in the selected state. The default color is blue, which can also be changed by applying themes.