ComponentDeprecatednavigation0.81 KB gzipZero dependencies

Scroll Spy V2

Horizontal scroll-spy nav v2 with sliding active pill.

This component is deprecated. Use scroll-spy-nav for new projects.

Preview

Live Preview
Open ↗

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add scroll-spy-v2

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { ScrollSpyV2 } from "@/components/ui/scroll-spy-v2"; <ScrollSpyV2 />

Source code

scroll-spy-v2.tsx + 1 helper

Zero third-party dependencies (2 local files shown in tabs below).

tsxscroll-spy-v2.tsx66 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export interface ScrollSpyV2Props extends React.HTMLAttributes<HTMLElement> {  sections: { id: string; label: string }[];} /** Horizontal scroll-spy nav v2: sliding active indicator pill. */export function ScrollSpyV2({ sections = [], className, ...props }: ScrollSpyV2Props) {  const [active, setActive] = React.useState(sections[0]?.id);  const listRef = React.useRef<HTMLUListElement>(null);  const itemRefs = React.useRef<Record<string, HTMLButtonElement | null>>({});   React.useEffect(() => {    const observer = new IntersectionObserver(      (entries) => {

Props

PropTypeDescription
sections{ id: string; label: string }[]Configures sections. (Default: [])