Skip to content
API 风格:

Tabbar ​

App-level bottom navigation: active item index (controlled modelValue with an internal fallback), icon / active icon, and badges (numeric overflow 99+ or a dot). Routing is intentionally not integrated (the select + update:modelValue events are emitted; the app wires navigation itself).

Active index clamping, badge formatting, class names and aria labels all come from the pure functions in @lh-ui/share/core/tabbar.

Basic Usage ​

items holds the tab entries (text is required; icon / activeIcon are optional). The demo uses :fixed="false" so it renders inline; in a real app fixed pins the bar to the viewport bottom:

Basic Usage
vue
<script setup lang="ts">
import { ref } from 'vue'
import { LhTabbar } from '@lh-ui/vue3'

const active = ref(0)
const items = [
  { text: 'Home', icon: 'home' },
  { text: 'Explore', icon: 'search' },
  { text: 'Mine', icon: 'user' },
]
</script>

<template>
  <!-- Basic usage -->
  <LhTabbar v-model="active" :items="items" :fixed="false" />
</template>
vue
<script>
import { LhTabbar } from '@lh-ui/vue3'

export default {
  components: { LhTabbar },
  data() {
    return {
      active: 0,
      items: [
        { text: 'Home', icon: 'home' },
        { text: 'Explore', icon: 'search' },
        { text: 'Mine', icon: 'user' },
      ],
    }
  },
}
</script>

<template>
  <!-- Basic usage -->
  <LhTabbar v-model="active" :items="items" :fixed="false" />
</template>

On switch the component emits update:modelValue (the new index) and select (the index of the active item, consistent with the five-platform contract); binding v-model makes it controlled, otherwise the internal state is used:

vue
<LhTabbar :items="items" @select="(index) => router.push(items[index].path)" />

Badges and Disabled Items ​

badge is either a number (>99 shows 99+) or true (dot); dot is a dot hint and is overridden by badge when both are set; disabled grays the item out and blocks clicks:

Badges and Disabled Items
vue
<script setup lang="ts">
import { ref } from 'vue'
import { LhTabbar } from '@lh-ui/vue3'

const active = ref(0)
const items = [
  { text: 'Messages', icon: 'message', badge: 5 },
  { text: 'Tasks', icon: 'task', badge: 120 },
  { text: 'Activity', icon: 'star', dot: true },
  { text: 'Mine', icon: 'user', disabled: true },
]
</script>

<template>
  <!-- Badges and disabled items -->
  <LhTabbar v-model="active" :items="items" :fixed="false" />
</template>
vue
<script>
import { LhTabbar } from '@lh-ui/vue3'

export default {
  components: { LhTabbar },
  data() {
    return {
      active: 0,
      items: [
        { text: 'Messages', icon: 'message', badge: 5 },
        { text: 'Tasks', icon: 'task', badge: 120 },
        { text: 'Activity', icon: 'star', dot: true },
        { text: 'Mine', icon: 'user', disabled: true },
      ],
    }
  },
}
</script>

<template>
  <!-- Badges and disabled items -->
  <LhTabbar v-model="active" :items="items" :fixed="false" />
</template>

Fixed Bottom and Safe Area ​

fixed (default true) pins the bar to the viewport bottom with z-index 1050 (above the navbar, below the overlay stack); placeholder (default true) renders an equal-height spacer so content does not collapse; safeAreaInsetBottom (default true) adds safe-area padding on notched screens:

vue
<LhTabbar :items="items" v-model="active" />
<!-- Equivalent to the defaults: fixed + placeholder + safe-area-inset-bottom all on -->

API ​

Tabbar Props ​

PropDescriptionTypeDefault
modelValueActive item index (controlled; internal fallback when omitted)number—
itemsTab entriesLhTabbarItem[]() => []
fixedFixed to bottombooleantrue
placeholderSpacer when fixedbooleantrue
safeAreaInsetBottomBottom safe-area paddingbooleantrue
labelAccessible name (defaults to "lh-tabbar")string—
sxsx quick-layout propsLhSxProps—

Tabbar Items ​

PropDescriptionTypeDefault
textTab labelstring—
iconIcon namestring—
activeIconIcon name for the active state (falls back to icon)string—
dotDot hint (mutually exclusive with badge: badge wins)booleanfalse
badgeNumeric badge (>99 shows 99+; true renders a dot)number | true—
disabledDisable the itembooleanfalse

Tabbar Events ​

EventDescriptionCallback
update:modelValueActive index change(index: number)
selectEmitted on click of a non-disabled item(index: number)

Accessibility ​

  • Each item is a real <button>; aria-label defaults to "{text}, item {n}", prefixed with "current" for the active item
  • The active item carries aria-current="true"; disabled items carry the disabled attribute
  • An out-of-range modelValue is clamped to a valid index (core's clampTabbarIndex)

Beauty of tradition, foundation of code