Skip to content

Tabbar

Bottom navigation bar, used for switching between different pages.

Basic Usage

v-model is the binding value, representing the index value or name of the selected tab.

html
<wd-tabbar v-model="tabbar">
  <wd-tabbar-item title="Home" icon="home"></wd-tabbar-item>
  <wd-tabbar-item title="Category" icon="cart"></wd-tabbar-item>
  <wd-tabbar-item title="My" icon="user"></wd-tabbar-item>
</wd-tabbar>
typescript
import { ref } from 'vue'

const tabbar = ref(1)

Match by Name

By setting the name property, you can match the selected tab by name.

html
<wd-tabbar v-model="tabbar">
  <wd-tabbar-item name="home" title="Home" icon="home"></wd-tabbar-item>
  <wd-tabbar-item name="cart" title="Category" icon="cart"></wd-tabbar-item>
  <wd-tabbar-item name="setting" title="Settings" icon="setting"></wd-tabbar-item>
  <wd-tabbar-item name="user" title="My" icon="user"></wd-tabbar-item>
</wd-tabbar>
typescript
import { ref } from 'vue'

const tabbar = ref('home')

Badge Tips

By setting the value property, you can display badge tips, and by setting the is-dot property, a small red dot will be displayed in the upper right corner of the icon.

html
<wd-tabbar v-model="tabbar">
  <wd-tabbar-item is-dot :value="2" title="Dot" icon="home"></wd-tabbar-item>
  <wd-tabbar-item :value="2" icon="cart" title="Category"></wd-tabbar-item>
  <wd-tabbar-item :value="30" title="My" icon="user"></wd-tabbar-item>
  <wd-tabbar-item :value="200" title="Max Value" icon="user"></wd-tabbar-item>
</wd-tabbar>
typescript
import { ref } from 'vue'

const tabbar = ref(1)

Floating Tab Bar

By setting the shape property to round, you can set the tab bar to floating style.

html
<wd-tabbar shape="round" v-model="tabbar">
  <wd-tabbar-item title="Home" is-dot :value="2" icon="home"></wd-tabbar-item>
  <wd-tabbar-item title="Category" :value="2" icon="cart"></wd-tabbar-item>
  <wd-tabbar-item title="Photos" :value="30" icon="photo"></wd-tabbar-item>
  <wd-tabbar-item title="My" :value="200" icon="user"></wd-tabbar-item>
</wd-tabbar>
typescript
import { ref } from 'vue'

const tabbar = ref(1)

Custom Icon

By using <template #icon>, you can customize the tab's icon.

html
<wd-tabbar v-model="tabbar">
  <wd-tabbar-item :value="2" title="Home" icon="home"></wd-tabbar-item>
  <wd-tabbar-item :value="2" icon="cart" title="Category">
    <template #icon>
      <wd-img round height="40rpx" width="40rpx" src="https://registry.npmmirror.com/wot-design-uni-assets/*/files/panda.jpg"></wd-img>
    </template>
  </wd-tabbar-item>
  <wd-tabbar-item :value="3" title="My" icon="user"></wd-tabbar-item>
</wd-tabbar>
typescript
import { ref } from 'vue'

const tabbar = ref(1)

Custom Color

By setting active-color and inactive-color properties, you can customize the color of active and inactive tabs.

html
<wd-tabbar v-model="tabbar" active-color="#ee0a24" inactive-color="#7d7e80">
  <wd-tabbar-item is-dot :value="2" title="Dot" icon="home"></wd-tabbar-item>
  <wd-tabbar-item :value="2" icon="cart" title="Category"></wd-tabbar-item>
  <wd-tabbar-item :value="30" title="My" icon="user"></wd-tabbar-item>
  <wd-tabbar-item :value="200" title="Max Value" icon="photo"></wd-tabbar-item>
  <wd-tabbar-item :value="10" title="Service" icon="chat"></wd-tabbar-item>
</wd-tabbar>
typescript
import { ref } from 'vue'

const tabbar = ref(1)

Listen to Switch Events

By listening to the change event, you can get the value of the selected tab.

html
<wd-tabbar v-model="tabbar" @change="handleChange" active-color="#ee0a24" inactive-color="#7d7e80">
  <wd-tabbar-item title="Home" icon="home"></wd-tabbar-item>
  <wd-tabbar-item title="Category" icon="cart"></wd-tabbar-item>
  <wd-tabbar-item title="My" icon="user"></wd-tabbar-item>
  <wd-tabbar-item title="Photos" icon="photo"></wd-tabbar-item>
  <wd-tabbar-item title="Service" icon="chat"></wd-tabbar-item>
</wd-tabbar>
typescript
import { ref } from 'vue'

const tabbar = ref(1)

function handleChange({ value }: { value: string }) {
  show(`Selected tab:${value}`)
}

Fixed Bottom

By setting the fixed property, you can fix the tab bar at the bottom; by setting the placeholder property, you can generate a placeholder element of the same height at the tab position when fixed at the bottom.

html
<wd-tabbar fixed v-model="tabbar" bordered safeAreaInsetBottom placeholder>
  <wd-tabbar-item :value="2" is-dot title="Home" icon="home"></wd-tabbar-item>
  <wd-tabbar-item title="Category" icon="cart"></wd-tabbar-item>
  <wd-tabbar-item title="My" icon="user"></wd-tabbar-item>
  <wd-tabbar-item :value="200" title="Photos" icon="photo"></wd-tabbar-item>
  <wd-tabbar-item :value="10" title="Service" icon="chat"></wd-tabbar-item>
</wd-tabbar>
typescript
import { ref } from 'vue'

const tabbar = ref(1)

Attributes

ParameterDescriptionTypeOptionsDefaultVersion
model-value / v-modelIndex value or name of the selected tabnumber / string-00.1.27
fixedWhether to fix at the bottomboolean-false0.1.27
safeAreaInsetBottomWhether to set bottom safe area (iPhone X type devices)boolean-false0.1.27
borderedWhether to show top borderboolean-true0.1.27
shapeShape of the tab barTabbarShape'default' / 'round''default'0.1.27
activeColorColor of active tabstring--0.1.27
inactiveColorColor of inactive tabstring--0.1.27
placeholderWhether to generate a placeholder element of the same height at the tab position when fixed at the bottomboolean-false0.1.27
zIndexZ-index of tabbar componentnumber-5000.1.27

Events

Event NameDescriptionParametersVersion
changeTriggered when tabbar tab switches{ value }0.1.27

External Style Classes

Class NameDescriptionVersion
custom-classRoot node style class0.1.27
custom-styleRoot node style0.1.27

TabbarItem Attributes

ParameterDescriptionTypeOptionsDefaultVersion
titleTitle of the tabstring--0.1.27
nameUnique identifierstring / number--0.1.27
iconIconstring--0.1.27

Source Code

Documentation
Component

Released under the MIT License.

Released under the MIT License.