{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "scroll-progress",
  "type": "registry:component",
  "title": "Scroll Progress",
  "description": "A thin bar fixed to the top of the viewport that fills as the page, or one element, is scrolled through.",
  "categories": [
    "motion"
  ],
  "dependencies": [
    "motion"
  ],
  "registryDependencies": [
    "@rivier-ui/theme",
    "@rivier-ui/cn",
    "@rivier-ui/motion"
  ],
  "files": [
    {
      "path": "registry/motion/scroll-progress.tsx",
      "type": "registry:component",
      "target": "components/motion/scroll-progress.tsx",
      "content": "\"use client\";\n/**\n * @name scroll-progress\n * @category motion\n * @description A thin bar fixed to the top of the viewport that fills as the page, or one element, is scrolled through.\n * @when Long reading pages: an article, documentation, a case study. Pass `target` to follow the article rather than the whole page. Not a loading indicator (use a progress control for that).\n * @example\n * <ScrollProgress />\n *\n * const article = useRef<HTMLElement>(null);\n * <ScrollProgress target={article} className=\"h-1\" />\n * <article ref={article}>…</article>\n */\nimport { motion, useScroll, type HTMLMotionProps } from \"motion/react\";\nimport type { RefObject } from \"react\";\nimport { cn } from \"@/lib/cn\";\nimport { useMotionSafe } from \"@/lib/motion\";\n\nexport type ScrollProgressProps = HTMLMotionProps<\"div\"> & {\n  /** Follow this element (from its top reaching the top of the viewport to its end reaching the bottom) instead of the page. */\n  target?: RefObject<HTMLElement | null>;\n};\n\n/**\n * Decoration: aria-hidden, and it only ever changes scaleX. It is not rendered on the server or under\n * reduced motion, so nothing is drawn until it can show the real position.\n */\nexport function ScrollProgress({ className, target, style, ...props }: ScrollProgressProps) {\n  const safe = useMotionSafe();\n  const { scrollYProgress } = useScroll(target ? { target, offset: [\"start start\", \"end end\"] } : undefined);\n  if (!safe) return null;\n\n  return (\n    <motion.div\n      aria-hidden=\"true\"\n      data-slot=\"scroll-progress\"\n      className={cn(\"pointer-events-none fixed inset-x-0 top-0 z-50 h-0.5 origin-left bg-primary rtl:origin-right\", className)}\n      {...props}\n      style={{ ...style, scaleX: scrollYProgress }}\n    />\n  );\n}\n"
    }
  ],
  "meta": {
    "category": "motion",
    "when": "Long reading pages: an article, documentation, a case study. Pass `target` to follow the article rather than the whole page. Not a loading indicator (use a progress control for that).",
    "example": "<ScrollProgress />\n\nconst article = useRef<HTMLElement>(null);\n<ScrollProgress target={article} className=\"h-1\" />\n<article ref={article}>…</article>",
    "client": true
  }
}
