Skip to content
← Components

Scroll Progress

Scroll Progress brings controlled expression to your interface.

Open ↗

Make it yours.

Install the editable source and its dependencies into your React + Tailwind project.

Scroll horizontally for long lines
pnpm dlx shadcn@4.0.8 add http://localhost:3000/r/scroll-progress.json

Use it

Scroll horizontally for long lines
"use client";
import { ScrollProgress } from "@/components/jez-ui/ui/scroll-progress";

export default function Example() {
  return (
    <>
      <div className="h-96">
        <ScrollProgress />
        <h3 className="text-2xl">A sense of where you are.</h3>
        <p className="mt-4 text-sm">
          The thin line at the top tracks this page as you scroll.
        </p>
      </div>
    </>
  );
}

Props & types

Scroll horizontally for long lines
React.ComponentProps<typeof motion.div>

Source

View 2 source files

registry/ui/scroll-progress.tsx

Scroll horizontally for long lines
"use client";
import * as React from "react";
import { cn } from "./utils";
import { motion, useScroll } from "motion/react";
export function ScrollProgress({
  className,
  style,
  ...props
}: React.ComponentProps<typeof motion.div>) {
  const { scrollYProgress } = useScroll();
  return (
    <motion.div
      {...props}
      aria-hidden="true"
      className={cn(
        "fixed inset-x-0 top-0 z-50 h-1 origin-left bg-primary",
        className,
      )}
      style={{ scaleX: scrollYProgress, ...style }}
    />
  );
}

registry/ui/utils.ts

Scroll horizontally for long lines
import { clsx, type ClassValue } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...values: ClassValue[]) {
  return twMerge(clsx(values));
}

Dependencies

motion@13.2.0 · clsx@2.1.1 · tailwind-merge@3.5.0

Accessibility & behaviour

Respect reduced-motion preferences. Decorative effects must not carry essential information. WebGL scenes include a static fallback and only render while visible.

Read the accessibility and performance guide →