Skip to content

Bottom Navigation Bar Component

Bottom navigation bar, used for switching between different pages.

📌 Platform Compatibility

APP(vue)H5WeChat Mini ProgramAlipay Mini Program

🏯 Basic Usage Example

html
<hy-tabbar-group v-model="current" @change="onChange">
    <hy-tabbar-item title="Home" icon="home"></hy-tabbar-item>
    <hy-tabbar-item title="Categories" icon="class"></hy-tabbar-item>
    <hy-tabbar-item title="Mine" icon="mine"></hy-tabbar-item>
</hy-tabbar-group>

<!-- Encapsulated component template -->
<hy-tabbar v-model="fixedCurrent" :list="list" activeColor="red"></hy-tabbar>
ts
import { ref } from 'vue';

const current = ref(0);
const fixedCurrent = ref('0');
const list = [
    { name: 'Home', icon: IconConfig.HOME },
    { name: 'Categories', icon: IconConfig.HOME },
    { name: 'Shopping Cart', icon: IconConfig.HOME, badge: 10 },
    { name: 'Mine', icon: IconConfig.HOME },
];
javascript
import { IconConfig } from '@hy-app/ui';

const list = [
    { name: 'Home', icon: IconConfig.HOME },
    { name: 'Categories', icon: IconConfig.HOME },
    { name: 'Shopping Cart', icon: IconConfig.HOME, badge: 10 },
    { name: 'Mine', icon: IconConfig.HOME },
];

Badge Notification

  • badgeProp: Receives badge parameters

Note

When isDot is true, value must have a value; when there is no number, you can fill in true, otherwise it will not be displayed

html
<hy-tabbar-group
    :custom-style="{ marginBottom: '20px' }"
    :badgeProps="{ isDot: true }"
    v-model="current"
    @change="onChange"
>
    <hy-tabbar-item title="Home" icon="home"></hy-tabbar-item>
    <hy-tabbar-item title="Categories" icon="class"></hy-tabbar-item>
    <hy-tabbar-item title="Mine" icon="mine" :value="true"></hy-tabbar-item>
</hy-tabbar-group>

<hy-tabbar-group v-model="current" @change="onChange">
    <hy-tabbar-item title="Home" icon="home" :value="10"></hy-tabbar-item>
    <hy-tabbar-item title="Categories" icon="class"></hy-tabbar-item>
    <hy-tabbar-item title="Mine" icon="mine"></hy-tabbar-item>
</hy-tabbar-group>

Rounded Navigation Bar

html
<hy-tabbar-group v-model="current" @change="onChange" shape="circle">
    <hy-tabbar-item title="Home" icon="home"></hy-tabbar-item>
    <hy-tabbar-item title="Categories" icon="class"></hy-tabbar-item>
    <hy-tabbar-item title="Mine" icon="mine"></hy-tabbar-item>
</hy-tabbar-group>

Rounded Navigation Bar

html
<hy-tabbar-group v-model="current" @change="onChange" activeColor="red" inactiveColor="green">
    <hy-tabbar-item title="Home" icon="home"></hy-tabbar-item>
    <hy-tabbar-item title="Categories" icon="class"></hy-tabbar-item>
    <hy-tabbar-item title="Mine" icon="mine"></hy-tabbar-item>
</hy-tabbar-group>

icon Slot

html
<hy-tabbar-group v-model="current" @change="onChange">
    <hy-tabbar-item title="Home" icon="home">
        <template #icon>
            <hy-image :src="config.avatar" width="30" height="30"></hy-image>
        </template>
    </hy-tabbar-item>
    <hy-tabbar-item title="Categories" icon="class"></hy-tabbar-item>
    <hy-tabbar-item title="Mine" icon="mine"></hy-tabbar-item>
</hy-tabbar-group>

API

TabBar Props

ParameterDescriptionTypeDefault
modelValueIndex of the selected itemnumber0
listNavigation bar data collectionTabBarListVo[][]
fixedWhether fixed at the bottombooleantrue
placeholderWhether to show a placeholder elementbooleanfalse
colorIcon and font colorstring-
baseBgColorTrack colorstring-
bgColorBackground colorstring-
activeColorActive circular background colorstring-
badgePropsBadge API propertiesHyBadgeProps-
customStyleDefine external styles to be usedCSSProperties-
customClassCustom external class namestring-

list

ParameterDescriptionTypeDefault
nametabBar namestring-
iconicon or imagestring-
badgeBadge valuenumber-

TabBarGroup Props

ParameterDescriptionTypeDefault
modelValueIndex of the selected itemnumber0
fixedWhether fixed at the bottombooleanfalse
borderWhether to show the top borderbooleantrue
placeholderWhether to show a placeholder elementbooleantrue
shapeShape of the navigation barstring'square'
bgColorBackground colorstring-
activeColorActive colorstring-
inactiveColorInactive colorstring-
safeAreaInsetBottomBottom safe area adaptation - mainly used for iPhone X and above modelsbooleantrue
iconSizeIcon sizestring|number-
fontSizeText sizestring|number-
badgePropsBadge propertiesHyBadgeProps-
zIndexz-index levelnumber10086
customStyleDefine external styles to be usedCSSProperties-
customClassCustom external class namestring-

TabBarItem Props

ParameterDescriptionTypeDefault
iconIconstring-
titleTitlestring-
nameUnique identifierstring|number-
valueBadge display value; when the badge is a dot, value must be set to true or have a valuestring|number|boolean-

Events

TabBar Emits

Event NameDescriptionCallback Parameters
changeUpdate selected indexvalue: number

TabBarGroup Emits

Event NameDescriptionCallback Parameters
changeUpdate selected index{value: string | number}

Slots

TabBar Slots

Note

The tabBar icon slot has no effect in mini programs

Slot NameDescriptionParameters
iconIcon slot-

TabBarItem Slots

Slot NameDescriptionParameters
iconIcon slot-

Typings

Type Description
ts
export interface TabBarItem {
    /**
     * Title
     * */
    name: string;
    /**
     * icon or image
     * */
    icon: string;
    /**
     * Badge value
     * */
    badge?: number;
}
03:29