Booting Environment...

Scroll Spy

A utility component that automatically tracks the active section within a scrolling container and highlights the corresponding navigation items.

Installation

npx raya-ui@latest add scroll-spy

File Structure

your-project
components
ui
scroll-spy
ScrollSpy.vue
ScrollSpyNav.vue
ScrollSpyLink.vue
ScrollSpyViewport.vue
ScrollSpySection.vue

API Reference

ScrollSpy (Root)

container
HTMLElement | null
window

Crucial: A reference to the scrolling element that contains your viewport. If omitted, it defaults to tracking the browser's window scroll.

orientation
enum
"vertical"

Defines layout flow context. vertical implies a side-by-side flex-row. horizontal implies stacked flex-col.

offset
number
0

Top margin offset (in pixels) for triggering section activation.

ScrollSpyNav

indicator
boolean
false

Enables the animated moving line indicator underneath or beside the active navigation item.

indicatorPosition
enum
"before"

Position of the animated line. Accepts 'before' (Left/Top) or 'after' (Right/Bottom).

Introduction

Sidebar layout uses orientation="vertical".

Installation

The indicator tracks section boundaries.

Configuration

Customize offsets and behavior easily.

Settings
0px