Scroll Progress
atroui/scroll-progressFreeComponent
Reading-progress bar driven by scroll position.
Install it
npx shadcn@latest add https://atroui.com/r/scroll-progress.jsonSource
1"use client"23import {4 motion,5 type SpringOptions,6 useScroll,7 useSpring,8} from "motion/react"9import type { RefObject } from "react"1011import { cn } from "@/lib/utils"1213export type ScrollProgressProps = {14 className?: string15 springOptions?: SpringOptions16 containerRef?: RefObject<HTMLDivElement | null>17}1819const DEFAULT_SPRING_OPTIONS: SpringOptions = {20 stiffness: 200,21 damping: 50,22 restDelta: 0.001,23}2425export function ScrollProgress({26 className,27 springOptions,28 containerRef,29}: ScrollProgressProps) {30 const { scrollYProgress } = useScroll({31 container: containerRef,32 })3334 const scaleX = useSpring(scrollYProgress, {35 ...DEFAULT_SPRING_OPTIONS,36 ...(springOptions ?? {}),37 })3839 return (40 <motion.div41 className={cn("inset-x-0 top-0 h-1 origin-left", className)}42 style={{43 scaleX,44 }}45 />46 )47}
What it pulls in
npm packages
Other registry items
Files it writes
More from atroui
All 81 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Breadcrumbsbreadcrumbs | atroui | Components | Free | 2 deps | |
| Buttonbutton | atroui | Components | Free | 2 deps | |
| Cardcard | atroui | Components | Free | no deps | |
| Fade Infade-in | atroui | Components | Free | 1 dep | |
| Form Selectform-select | atroui | Components | Free | 2 deps | |
| Founder Avatarfounder-avatar | atroui | Components | Free | 1 dep | |
| Logologo | atroui | Components | Free | no deps | |
| Mockup Framemockup-frame | atroui | Components | Free | no deps |
