Skip to content

IndexBar ​

연락처 스타일 인덱스 바: 알파벳 사이드바 + 앵커 그룹. scroll-spy 활성화(resolveActiveIndex)와 터치 판정(hitIndexBar)은 모두 @lh-ui/share/core/index-bar 순수 함수를 사용합니다. 스크롤载体는 자체 렌더링 scroll-view(scroll-into-view 앵커 이동 + scroll 이스트 구동 scroll-spy)입니다.

플랫폼 차이 (등록): 앵커 측정은 H5가 동기 DOM, MP가 createSelectorQuery(getLhRect adapter 경유)입니다. 이동은 일괄 scroll-into-view입니다. web 3종은 DOM scrollTo, wxapp/alipay는 각 문서를 참조하세요.

기본 사용법 ​

vue
<template>
  <lh-index-bar :index-list="['A', 'B', 'C']" @select="onSelect">
    <lh-index-bar-group v-for="key in ['A', 'B', 'C']" :key="key" :index="key">
      <lh-index-bar-item v-for="name in groups[key]" :key="name">
        {{ name }}
      </lh-index-bar-item>
    </lh-index-bar-group>
  </lh-index-bar>
</template>

<script setup lang="ts">
import { ref } from 'vue'

const current = ref('')
const groups: Record<string, string[]> = {
  A: ['阿白', '阿黄'],
  B: ['柏舟', '薄荷'],
  C: ['春日', '椿'],
}

function onSelect(index: string) {
  current.value = index
}
</script>

스티키 헤더와 강조색 ​

sticky로 그룹 헤더 고정 의도를 등록합니다(이端 scroll-view에는 sticky 의미가 없어 CSS sticky로 렌더링). sticky-offset-top은 내비바 예약 오프셋, highlight-color는 활성 색상을 덮어씁니다:

vue
<lh-index-bar :index-list="['甲', '乙', '丙']" highlight-color="#c0392b">
  <lh-index-bar-group index="甲"><lh-index-bar-item>甲一</lh-index-bar-item></lh-index-bar-group>
  <lh-index-bar-group index="乙"><lh-index-bar-item>乙一</lh-index-bar-item></lh-index-bar-group>
  <lh-index-bar-group index="丙"><lh-index-bar-item>丙一</lh-index-bar-item></lh-index-bar-group>
</lh-index-bar>

속성 ​

속성설명타입기본값
indexList인덱스 항목 배열 (미지정 시 A-Z 26항, 빈 배열은 사이드바 없음)string[]A-Z
sticky그룹 헤더 고정 (등록: 이端은 CSS sticky로 강등)booleantrue
stickyOffsetTop고정 오프셋 px (내비바 예약)number0
highlightColor활성 색상 (미지정 시 indexBar.highlightColor 토큰)string—
customClass커스텀 클래스 (루트 노드로 전달)string—
sxLhSxPropsLhSxProps—

이벤트 ​

이벤트설명
select사이드바 항목 클릭 / 터치 index: string

슬롯 ​

슬롯설명
default그룹 콘텐츠 (lh-index-bar-group / lh-index-bar-item)
item인덱스 항목 커스텀 렌더링 { index }

LhIndexBarGroup 속성 ​

속성설명타입기본값
index그룹 키 (필수, indexList와 정렬)string—
customClass커스텀 클래스 (루트 노드로 전달)string—
sxLhSxPropsLhSxProps—

LhIndexBarItem 속성 ​

속성설명타입기본값
disabled비활성화 (대비 감소)booleanfalse
customClass커스텀 클래스 (루트 노드로 전달)string—
sxLhSxPropsLhSxProps—

접근성 ​

  • 루트 요소에 role="navigation" + aria-label="인덱스 바".