# Tabbar ### Install ```js import Vue from 'vue'; import { Tabbar, TabbarItem } from 'vant'; Vue.use(Tabbar); Vue.use(TabbarItem); ``` ## Usage ### Basic Usage ```html Tab Tab Tab Tab ``` ```js export default { data() { return { active: 0 } } } ``` ### Match by name ```html Tab Tab Tab Tab ``` ```js export default { data() { return { active: 'home' } } } ``` ### Show Badge ```html Tab Tab Tab Tab ``` ### Custom Icon Use `icon` slot to custom icon ```html Custom Tab Tab ``` ```js export default { data() { return { active: 0, icon: { active: 'https://img.yzcdn.cn/vant/user-active.png', inactive: 'https://img.yzcdn.cn/vant/user-inactive.png' } } } } ``` ### Custom Color ```html Tab Tab Tab Tab ``` ### Change Event ```html Tab1 Tab2 Tab3 Tab4 ``` ```js import { Notify } from 'vant'; export default { methods: { onChange(index) { Notify({ type: 'primary', message: index }); } } } ``` ### Route Mode ```html Tab Tab ``` ## API ### Tabbar Props | Attribute | Description | Type | Default | |------|------|------|------| | v-model | Identifier of current tab | *string \| number* | `0` | | fixed | Whether to fixed bottom | *boolean* | `true` | | border | Whether to show border | *boolean* | `true` | | z-index | Z-index | *number* | `1` | | active-color | Color of active tab item | *string* | `#1989fa` | | inactive-color | Color of inactive tab item | *string* | `#7d7e80` | | route | Whether to enable route mode | *boolean* | `false` | | safe-area-inset-bottom | Whether to enable bottom safe area adaptation | *boolean* | `false` | ### Tabbar Events | Event | Description | Arguments | |------|------|------| | change | Triggered when change active tab | active: index of current tab | ### TabbarItem Props | Attribute | Description | Type | Default | |------|------|------|------| | name | Identifier | *string \| number* | Item index | | icon | Icon name | *string* | - | | dot | Whether to show red dot | *boolean* | - | | info | Content of the badge | *string \| number* | - | | url | Link | *string* | - | | to | Target route of the link, same as to of vue-router | *string \| object* | - | | replace | If true, the navigation will not leave a history record | *boolean* | `false` | ### TabbarItem Slots | Name | Description | SlotProps | |------|------|------| | icon | Custom icon | active |