Skip to content

Bottom Navigation Bar Component ​

A bottom navigation bar used to switch between different pages.

📌 Platform Differences ​

APP(vue)H5WeChat Mini ProgramAlipay Mini Program
✔✔✔✔

🏯 Basic Usage ​

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>

<!-- Wrapped 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: '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: 'Cart', icon: IconConfig.HOME, badge: 10 },
    { name: 'Mine', icon: IconConfig.HOME },
];

Badge Indicator ​

  • badgeProp: Receives the badge parameter

Note

When isDot is true, value must have a value; if 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 Value
modelValueIndex of the selected itemnumber0
listNavigation bar data collectionTabBarListVo[][]
fixedWhether to fix at the bottombooleantrue
placeholderWhether to show a placeholder elementbooleanfalse
colorIcon and font colorstring-
baseBgColorTrack colorstring-
bgColorBackground colorstring-
activeColorActive circle background colorstring-
badgePropsBadge API propertiesHyBadgeProps-
customStyleDefine external styles to be usedCSSProperties-
customClassCustom external class namestring-

list ​

ParameterDescriptionTypeDefault Value
nametabBar namestring-
iconIcon name or imagestring-
badgeBadge valuenumber-

TabBarGroup Props ​

ParameterDescriptionTypeDefault Value
modelValueIndex of the selected itemnumber0
fixedWhether to fix 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 for iPhone X and newer modelsbooleantrue
iconSizeIcon sizestring|number-
fontSizeFont sizestring|number-
badgePropsPartial badge propertiesHyBadgeProps-
zIndexz-index levelnumber10086
customStyleDefine external styles to be usedCSSProperties-
customClassCustom external class namestring-

TabBarItem Props ​

ParameterDescriptionTypeDefault Value
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
changeUpdates the selected indexvalue: number

TabBarGroup Emits ​

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

Slots ​

TabBar Slots ​

Note

The tabBar icon slot has no effect in mini programs.

Slot NameDescriptionAccepted Value
iconIcon slot-

TabBarItem Slots ​

Slot NameDescriptionAccepted Value
iconIcon slot-

Typings ​

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

CSS Variables ​

hy-tabbar ​

Variable NameDescriptionDefault Value
--hy-tabbar-heightHeight60px (bottom safe area is automatically added)
--hy-tabbar-radiusTop border radius15rpx 15rpx 0 0
--hy-tabbar-paddingPadding0 20rpx
--hy-tabbar-item-widthItem width60px
--hy-tabbar-indicator-sizeIndicator size50px
--hy-tabbar-circle-sizeRaised circle size40px

hy-tabbar-group ​

Variable NameDescriptionDefault Value
--hy-tabbar-group-heightHeight100rpx
--hy-tabbar-group-z-indexZ-index level500
--hy-tabbar-group-radiusCapsule mode border radiusFollows --hy-radius-semicircle (100px)
--hy-tabbar-group-borderTop borderFollows --hy-border-line

hy-tabbar-item ​

Variable NameDescriptionDefault Value
--hy-tabbar-item-icon-sizeIcon size40rpx
--hy-tabbar-item-title-font-sizeTitle font sizeFollows --hy-font-size-sm (24rpx)
--hy-tabbar-item-inactive-colorInactive colorFollows --hy-text-color--grey
12:33
battery