# IndexBar 인덱스 바
주소록식 인덱스 바: 오른쪽 알파벳 인덱스 + 그룹 앵커 위치 이동입니다. scroll-spy 활성화 변환
(resolveActiveIndex)과 터치 변환(hitIndexBar)은 모두 @lh-ui/share/core/index-bar
순수 로직을 소비합니다; 이 끝은 DOM 측정 + scrollTo 접착만 담당합니다.
인덱스 바 (클릭 / 터치로 그룹 위치 이동)
<template>
<div class="demo-col" style="gap: 18px">
<div class="index-demo-scroll">
<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>
</div>
<p class="demo-note">현재 인덱스: {{ current }}</p>
</div>
</template>
<script>
export default {
data: () => ({
current: '',
groups: {
A: ['아침', '아련'],
B: ['바다', '별무리'],
C: ['찬샘', '참나무'],
},
}),
methods: {
onSelect(index) {
this.current = index
},
},
}
</script>
# 상단 고정과 사용자 정의 강조
sticky는 그룹 헤더 상단 고정을 켭니다(기본 켜짐), sticky-offset-top은 내비게이션 바 자리
오프셋이며, highlight-color로 활성 인덱스 강조 색상을 사용자 정의합니다.
<LhIndexBar :index-list="['갑', '을', '병']" :sticky-offset-top="0" highlight-color="#c0392b">
<LhIndexBarGroup index="갑"><LhIndexBarItem>갑 하나</LhIndexBarItem></LhIndexBarGroup>
<LhIndexBarGroup index="을"><LhIndexBarItem>을 하나</LhIndexBarItem></LhIndexBarGroup>
<LhIndexBarGroup index="병"><LhIndexBarItem>병 하나</LhIndexBarItem></LhIndexBarGroup>
</LhIndexBar>
# Props
| 프로퍼티 | 설명 | 타입 | 기본값 |
|---|---|---|---|
| indexList | 인덱스 항목 배열 (미전달 시 기본 A-Z 26항; 빈 배열이면 측면 바 미 렌더링) | string[] | A-Z |
| sticky | 앵커 그룹 헤더 상단 고정 | boolean | true |
| stickyOffsetTop | 상단 고정 오프셋 px (내비게이션 바 자리 확보용) | number | 0 |
| highlightColor | 활성 인덱스 강조 색상 (미전달 시 indexBar.highlightColor 토큰 사용) | string | — |
| sx | sx 레이아웃 단축 속성 | LhSxProps | — |
# Events
| 이벤트 | 설명 | 페이로드 |
|---|---|---|
| select | 측면 바 인덱스 항목 클릭 / 터치 | index: string |
# Slots
| 슬롯 | 설명 | 페이로드 |
|---|---|---|
| default | 그룹 콘텐츠 (LhIndexBarGroup / LhIndexBarItem 짝) | — |
| item | 사용자 정의 인덱스 항목 렌더링 | { index } |
# LhIndexBarGroup Props
| 프로퍼티 | 설명 | 타입 | 기본값 |
|---|---|---|---|
| index | 그룹 인덱스 키 (indexList 항목과 정렬, 필수) | string | — |
| sx | sx 레이아웃 단축 속성 | LhSxProps | — |
# LhIndexBarItem Props
| 프로퍼티 | 설명 | 타입 | 기본값 |
|---|---|---|---|
| disabled | 비활성화 (대비도 낮춤) | boolean | false |
| sx | sx 레이아웃 단축 속성 | LhSxProps | — |
# 접근성
루트 요소 role="navigation" + aria-label="인덱스 바".
Copyright © 2024-2026 FengMo WenXue