Skip to content

TabBar ​

底部导航。v-model 为当前 item.key;内部用 HIcon 渲染图标。不内置路由。

文档内演示关闭 fixed / safe-area,避免遮挡文档页脚。

基础 ​

当前 key:home

vue
<script setup lang="ts">
import { ref } from 'vue'
import { Home, Search, User } from '@lucide/vue'
import { HTabBar } from 'happier-ui'
import type { HTabBarItem } from 'happier-ui'

const tab = ref('home')
const items: HTabBarItem[] = [
  { key: 'home', label: '首页', icon: Home },
  { key: 'search', label: '搜索', icon: Search },
  { key: 'me', label: '我的', icon: User },
]
</script>

<template>
  <h-tab-bar v-model="tab" :items="items" />
</template>

fixed 与 safeArea 默认均为 true,可独立关闭。

API ​

Types ​

ts
type HTabBarItem = {
  key: string
  label?: string
  icon?: Component
  disabled?: boolean
}

Props ​

名称类型默认说明
modelValuestring—当前选中 key
itemsHTabBarItem[]—必填;导航项
ariaLabelstring'主导航'nav 可访问名
fixedbooleantrue固定在视口底部
safeAreabooleantrue底部安全区

Emits ​

事件载荷说明
update:modelValuestring选中 key 变化

Slots ​

无。

无障碍 ​

  • nav + aria-label
  • 项为 button;选中 aria-current="page"
  • fixed / safe-area 默认开

MIT License