A utility that automatically highlights navigation items based on scroll position.
Sidebar layout uses orientation="vertical".
The indicator uses indicator="before".
Customize offsets and behavior easily.
npx shadcn-vue@latest add https://raya-ui.com/registry/scroll-spy.jsonOr manually:
npm install reka-ui @vueuse/core clsx tailwind-merge Nav on top, content below. Use orientation="horizontal" and indicator-position="after" for the bottom line.
Nav on the right. Use indicator-position="after" to show the line on the right edge.
| Prop | Type | Default | Description |
|---|---|---|---|
| indicator | boolean | false | Enables the moving active line indicator. |
| indicatorPosition | 'before' | 'after' | 'before' | Controls line position relative to the link. Vertical: before (Left), after (Right).Horizontal: before (Top), after (Bottom). |
| Prop | Type | Default | Description |
|---|---|---|---|
| container | HTMLElement | null | window | Crucial: A reference to the element that has overflow-y: auto. If omitted, it tracks the window scroll. |
| orientation | 'vertical' | 'horizontal' | 'vertical' | Controls the flex direction.vertical = Side-by-side (flex-row).horizontal = Stacked (flex-col). |
| offset | number | 0 | Offset from the top when scrolling/detecting. |