Scroll Progress
abui/scroll-progressFreeComponent
A scroll progress indicator that shows reading progress as a horizontal bar at the top or bottom of the viewport.
Live preview
live · rendered by the registry
Rendered by abui on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://abui.io/r/scroll-progress.jsonSource
1"use client"23import { motion, useScroll } from "motion/react"4import { cn } from "@/lib/utils"56interface ScrollProgressProps extends React.ComponentProps<typeof motion.div> {7 /**8 * Height of the progress bar in pixels9 * @default 210 */11 height?: number12 /**13 * Color of the progress bar14 * @default "bg-primary"15 */16 color?: string17 /**18 * Position of the progress bar19 * @default "top"20 */21 position?: "top" | "bottom"22 /**23 * Container element to track scroll progress for24 * If not provided, tracks the entire viewport25 */26 container?: React.RefObject<HTMLElement | null>27}2829function ScrollProgress({30 height = 4,31 color = "bg-primary",32 position = "top",33 className,34 container,35 ...props36}: ScrollProgressProps) {37 const { scrollYProgress } = useScroll({38 container: container as any,39 })4041 return (42 <motion.div43 data-slot="scroll-progress"44 className={cn(45 "left-0 right-0 z-50 origin-left",46 // Use fixed positioning for viewport scroll, allow override for container scroll47 !container && "fixed",48 position === "top" ? "top-0" : "bottom-0",49 color,50 className,51 )}52 style={{53 scaleX: scrollYProgress,54 height: `${height}px`,55 }}56 {...props}57 />58 )59}6061export { ScrollProgress }
What it pulls in
npm packages
Files it writes
More from abui
All 20 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Accordion Multiselectaccordion-multiselect | abui | Components | Free | 3 deps | |
| Breakpoint Displaybreakpoint-display | abui | Components | Free | no deps | |
| Color Swatch Selectorcolor-swatch-selector | abui | Components | Free | no deps | |
| Label Selectorlabel-selector | abui | Components | Free | 2 deps | |
| Radio Rowsradio-rows | abui | Components | Free | no deps | |
| Radio Tabsradio-tabs | abui | Components | Free | no deps | |
| Spinnerspinner | abui | Components | Free | 1 dep | |
| Text Gradienttext-gradient | abui | Components | Free | no deps |
