Componentnavigation1.06 KB gzipZero dependencies
ScrollSpyNav
Horizontal sticky navigation with active pill that slides under the active section, smooth scroll with reduced-motion fallback
Preview
Live Preview
Installation
Tokens guide →Add to your project via CLI (zero dependencies, code you own):
npx bigbullui add scroll-spy-navOr install the full npm package:
npm install bigbulluiUsage
tsx3 lines
import { ScrollSpyNav } from "@/components/ui/scroll-spy-nav" <ScrollSpyNav sections={sections} />Source code
scroll-spy-nav.tsx + 1 helperZero third-party dependencies (2 local files shown in tabs below).
tsxscroll-spy-nav.tsx128 lines
"use client"; import * as React from "react";import { cn } from "./lib/utils"; export interface Section { id: string; label: string;} export interface ScrollSpyNavProps extends React.HTMLAttributes<HTMLElement> { sections: Section[]; className?: string;} export function ScrollSpyNav({ sections = [], className, ...props }: ScrollSpyNavProps) { const [activeIndex, setActiveIndex] = React.useState(0); const refs = React.useRef<HTMLDivElement[]>(sections.map(() => null!));Props
| Prop | Type | Description |
|---|---|---|
| sections | Section[] | Configures sections. (Default: []) |
| className | string | Optional Tailwind or custom CSS classes merged with component styles. |