Getting Started
Components
Special Effects
Animations
Text Animations
Backgrounds
A description for Scroll Progress component.
motion-sv
Note: The scroll progress is shown below the navbar of the page.
scroll-progress.svelte
<script lang="ts"> import { ScrollProgress } from "$lib/components/magic/scroll-progress/index.js";</script>
<div class="z-10 rounded-lg p-4"> <ScrollProgress class="top-14" /> <h2 class="pb-4 font-bold">Note: The scroll progress is shown below the navbar of the page.</h2></div>Installation
pnpm dlx shadcn-svelte@latest add https://sv-animations.vercel.app/r/scroll-progress.json
Install dependencies
Install the required packages for this component:
pnpm add motion-sv
Copy the Source Code
Copy and paste the following code into your project:
scroll-progress.svelte
<script lang="ts"> import type { ClassValue } from "svelte/elements"; import { motion, useScroll } from "motion-sv"; import { cn } from "#lib/utils.js";
interface ScrollProgressProps { class?: ClassValue; }
let { class: className }: ScrollProgressProps = $props();
let scroll = $derived(useScroll());</script>
<motion.div class={cn( "fixed inset-x-0 top-0 z-50 h-1 origin-top-left bg-linear-to-r from-[#A97CF8] via-[#F38CB8] to-[#FDCC92]", className )} style={{ scaleX: scroll.scrollYProgress, }}/> index.ts
import ScrollProgress from "./scroll-progress.svelte";export { ScrollProgress };Folder Structure
Folder Structure
src/└── lib/ └── components/ └── magic/ └── scroll-progress/ ├── scroll-progress.svelte └── index.tsInstall and integrate the Svelte component documented below.https://sv-animations.vercel.app/magic/docs/components/scroll-progress/llms.txt
Follow the guide's installation and usage instructions.Match the project's existing structure, imports, and styles.Keep changes scoped to the component and verify it works.Reply with a short bullet list of completed changes.Usage
<script lang="ts"> import { ScrollProgress } from "#lib/components/magic/scroll-progress/index.js";</script>
<ScrollProgress />Props
Scroll Progress
A component for Scroll Progress.
| Name | Type | Default | Description |
|---|---|---|---|
class | ClassValue | "" | Additional CSS classes to apply |