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
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add scroll-spy-v2Or install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { ScrollSpyV2 } from "@/components/ui/scroll-spy-v2"; <ScrollSpyV2 />Source code
scroll-spy-v2.tsx + 1 helperZero 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
| Prop | Type | Description |
|---|---|---|
| sections | { id: string; label: string }[] | Configures sections. (Default: []) |