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
Open ↗

Installation

Tokens guide →

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

npx bigbullui add scroll-spy-nav

Or install the full npm package:

npm install bigbullui

Usage

tsx3 lines
import { ScrollSpyNav } from "@/components/ui/scroll-spy-nav" <ScrollSpyNav sections={sections} />

Source code

scroll-spy-nav.tsx + 1 helper

Zero 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

PropTypeDescription
sectionsSection[]Configures sections. (Default: [])
classNamestringOptional Tailwind or custom CSS classes merged with component styles.