본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

Jump Links

원문 보기 위키 갱신

Jump links는 페이지의 특정 섹션으로 빠르게 이동할 수 있는 내비게이션 컴포넌트예요. 스크롤 스파이(scroll spy)와 함께 사용하면 현재 보고 있는 섹션을 자동으로 강조할 수 있어요.

출처: 문서

본문

예제 (Examples)

이 예제들은 스크롤 스파이를 적용할 의미 있는 요소가 없어 정적 상태로 보여 줘요. 스크롤 스파이가 동작하는 모습은 React demos에서 확인할 수 있어요!

기본 (Basic)

중앙 정렬 목록 (With centered list)

라벨 포함 (With label)

Jump to first section in jump links with label example

Jump to second section in jump links with label example

세로 (Vertical)

세로 + 라벨 (Vertical with label)

Jump to vertical example sections with labels

하위 섹션이 있는 펼칠 수 있는 세로 (Expandable vertical with subsection)

Props

*required

Name Type Default Description
activeIndex number 0 활성화할 자식 Jump link의 인덱스.
alwaysShowLabel boolean true expandable을 사용할 때 라벨을 항상 표시할지 여부.
aria-label string typeof label === 'string' ? label : null 내부 nav 요소에 접근 가능한 라벨을 추가해요. 기본값은 label prop의 값이에요.
children React.ReactNode 자식 노드.
className string nav용 클래스.
expandable { default?: 'expandable' | 'nonExpandable'; sm?: 'expandable' | 'nonExpandable'; md?: 'expandable' | 'nonExpandable'; lg?: 'expandable' | 'nonExpandable'; xl?: 'expandable' | 'nonExpandable'; '2xl'?: 'expandable' | 'nonExpandable' } 각 브레이크포인트에서 언제 접고 펼칠지.
isCentered boolean 자식을 중앙 정렬할지 여부.
isExpanded boolean false 모바일에서 JumpLinks가 처음에 펼쳐진 상태인지 여부.
isVertical boolean 자식의 레이아웃이 세로인지 가로인지.
label React.ReactNode nav 요소에 추가할 라벨.
labelId string alwaysShowLabel이 적용됐거나 expandable 토글에 적용되는 사용자 지정 ID. aria-label과 aria-labelledby 관련 내부 로직에 사용돼요.
offset number 0 scrollPosition에 추가할 오프셋. 콘텐츠가 아래로 스크롤되는 마스트헤드가 있을 때 유용해요.
scrollableRef HTMLElement | (() => HTMLElement) | React.RefObject<HTMLElement | null> 스파이할 스크롤 가능한 요소의 참조. scrollableSelector보다 우선해요. scrollableRef나 scrollableSelector를 전달하지 않으면 스파이가 비활성화돼요.
scrollableSelector string 스파이할 스크롤 가능한 요소의 셀렉터. scrollableSelector나 scrollableRef를 전달하지 않으면 스파이가 비활성화돼요.
shouldReplaceNavHistory boolean false JumpLinksItem을 클릭했을 때 내비게이션 기록의 현재 항목을 교체할지 여부. 기본적으로 새 항목이 기록에 추가돼요.
toggleAriaLabel string 'Toggle jump links' expandable 토글의 aria label.

JumpLinksItem

*required

Name Type Default Description
href*required string 이 링크의 href.
children React.ReactNode span 안에 렌더링할 텍스트.
className string li에 추가할 클래스.
isActive boolean 이 항목이 활성 상태인지 여부. 부모 JumpLinks 컴포넌트가 scrollableSelector를 전달받으면 이를 설정해요.
node string | HTMLElement 스파이할 셀렉터 또는 HTMLElement.
onClick (ev: React.MouseEvent) => void 앵커 태그의 클릭 핸들러. 부모 JumpLinks 컴포넌트가 이를 사용해요.

Edit this page on GitHub

더 알아보기 (Learn more)