ComponentsBlocksDocsExamples

Alert
Calendar
Card
Chart
Data Grid
Update
Drawer
File Upload
Kanban
Kbd
Pagination
Resizable
Rating
Stepper
Scrollspy
Skeleton
Sortable
Sonner
Table
Textarea

Components

Scrollspy

UI Library:

Dynamically highlights navigation to indicate current visible section in viewport during page scroll

Installation

pnpm dlx shadcn@latest add @toui/scrollspy

Examples

Horizontal

API Reference

This component provides a scrollspy navigation system that highlights the current section in view and keeps the URL hash in sync.

Scrollspy Props

PropTypeDefault
children ReactNode
targetRef RefObject<HTMLElement | HTMLDivElement | Document>
onUpdate (id: string) => void
offset number0
smooth booleantrue
className string
dataAttribute string'scrollspy'
history booleantrue

Data Attributes

Data AttributeUsageDescription
data-slot="scrollspy"On the root wrapperIdentifies the main Scrollspy container.
data-scrollspy-anchorOn nav anchor elementsThe section id this anchor targets. Example: data-scrollspy-anchor="section-1"
data-scrollspy-offsetOn nav anchor elements (optional)Custom offset for this anchor (overrides global offset prop).
data-scrollspyOn the nav group (optional)Used for grouping anchors, e.g. for styling or nested scrollspy.
data-activeOn anchor elementsApplied to the currently active anchor.
PreviouseStepperNextSkeleton

On This Page

  • Installation
  • Examples
    • Horizontal
  • API Reference
    • Scrollspy Props
    • Data Attributes

We use cookies

We use cookies to ensure you get the best experience on our website. For more information on how we use cookies, please see our cookie policy.

By clicking Accept, you agree to our use of cookies.
Learn more.

Token UI

Components

  • Overview
  • Pricing
  • Marketplace
  • Features
  • Integrations
  • Pricing

Blocks

  • Charts
  • Team
  • Blog
  • Careers
  • Contact
  • Privacy

Examples

  • Help
  • Sales
  • Advertise

Docs

  • Twitter
  • Instagram
  • LinkedIn

© 2025 TOUI.dev. All rights reserved.

  • Terms and Conditions
  • Privacy Policy