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:
<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><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:
<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:
<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><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:
<LhTabbar :items="items" v-model="active" />
<!-- Equivalent to the defaults: fixed + placeholder + safe-area-inset-bottom all on -->API
Tabbar Props
| Prop | Description | Type | Default |
|---|---|---|---|
| modelValue | Active item index (controlled; internal fallback when omitted) | number | — |
| items | Tab entries | LhTabbarItem[] | () => [] |
| fixed | Fixed to bottom | boolean | true |
| placeholder | Spacer when fixed | boolean | true |
| safeAreaInsetBottom | Bottom safe-area padding | boolean | true |
| label | Accessible name (defaults to "lh-tabbar") | string | — |
| sx | sx quick-layout props | LhSxProps | — |
Tabbar Items
| Prop | Description | Type | Default |
|---|---|---|---|
| text | Tab label | string | — |
| icon | Icon name | string | — |
| activeIcon | Icon name for the active state (falls back to icon) | string | — |
| dot | Dot hint (mutually exclusive with badge: badge wins) | boolean | false |
| badge | Numeric badge (>99 shows 99+; true renders a dot) | number | true | — |
| disabled | Disable the item | boolean | false |
Tabbar Events
| Event | Description | Callback |
|---|---|---|
| update:modelValue | Active index change | (index: number) |
| select | Emitted on click of a non-disabled item | (index: number) |
Accessibility
- Each item is a real
<button>;aria-labeldefaults to "{text}, item {n}", prefixed with "current" for the active item - The active item carries
aria-current="true"; disabled items carry thedisabledattribute - An out-of-range
modelValueis clamped to a valid index (core's clampTabbarIndex)

