IndexBar
A contacts-style index bar: a right-side letter index plus anchored group positioning. The scroll-spy active computation (resolveActiveIndex) and the touch computation (hitIndexBar) all consume the pure logic in @lh-ui/share/core/index-bar; this side is only DOM measurement + scrollTo glue.
Basic Usage
Index bar (tap / touch to position a group)
A
Alan
Amber
B
Bella
Brian
C
Chloe
Claire
A
B
C
Current index:
vue
<script setup lang="ts">
import { ref } from 'vue'
import { LhIndexBar, LhIndexBarGroup, LhIndexBarItem } from '@lh-ui/vue3'
const current = ref('')
const groups: Record<string, string[]> = {
A: ['Alan', 'Amber'],
B: ['Bella', 'Brian'],
C: ['Chloe', 'Claire'],
}
function onSelect(index: string) {
current.value = index
}
</script>
<template>
<LhIndexBar :index-list="['A', 'B', 'C']" @select="onSelect">
<LhIndexBarGroup v-for="key in ['A', 'B', 'C']" :key="key" :index="key">
<LhIndexBarItem v-for="name in groups[key]" :key="name">{{ name }}</LhIndexBarItem>
</LhIndexBarGroup>
</LhIndexBar>
</template>Sticky headers and custom highlight
sticky enables sticky group headers (on by default); sticky-offset-top is the navbar placeholder offset; highlight-color customizes the active index highlight color.
Sticky + custom highlight color
X
Item X-1
Y
Item Y-1
Z
Item Z-1
X
Y
Z
API
IndexBar Props
| Prop | Description | Type | Default |
|---|---|---|---|
| index-list | Index item array (defaults to the 26 items A-Z when not passed; an empty array renders no sidebar) | string[] | A-Z |
| sticky | Sticky anchor group headers | boolean | true |
| sticky-offset-top | Sticky offset in px (for the navbar placeholder) | number | 0 |
| highlight-color | Active index highlight color (falls back to the indexBar.highlightColor token when not passed) | string | — |
IndexBar Events
| Event | Description | Callback |
|---|---|---|
| select | Tap / touch a sidebar index item | index: string |
IndexBar Slots
| Slot | Description | Scoped props |
|---|---|---|
| default | Group content (LhIndexBarGroup / LhIndexBarItem pairs) | — |
| item | Custom index item rendering | { index } |
IndexBarGroup Props
| Prop | Description | Type | Default |
|---|---|---|---|
| index | Group index key (aligned with an indexList item) | string | — |
IndexBarItem Props
| Prop | Description | Type | Default |
|---|---|---|---|
| disabled | Disabled (reduced contrast) | boolean | false |
IndexBarItem Slots
| Slot | Description |
|---|---|
| default | Item content |

