An infinite scrolling component that can be used to display text, images, or videos.
@jack
I've never seen anything like this before. It's amazing. I love it.
@jill
I don't know what to say. I'm speechless. This is amazing.
@john
I'm at a loss for words. This is amazing. I love it.
@jack
I've never seen anything like this before. It's amazing. I love it.
@jill
I don't know what to say. I'm speechless. This is amazing.
@john
I'm at a loss for words. This is amazing. I love it.
@jack
I've never seen anything like this before. It's amazing. I love it.
@jill
I don't know what to say. I'm speechless. This is amazing.
@john
I'm at a loss for words. This is amazing. I love it.
@jack
I've never seen anything like this before. It's amazing. I love it.
@jill
I don't know what to say. I'm speechless. This is amazing.
@john
I'm at a loss for words. This is amazing. I love it.
@jane
I'm at a loss for words. This is amazing. I love it.
@jenny
I'm at a loss for words. This is amazing. I love it.
@james
I'm at a loss for words. This is amazing. I love it.
@jane
I'm at a loss for words. This is amazing. I love it.
@jenny
I'm at a loss for words. This is amazing. I love it.
@james
I'm at a loss for words. This is amazing. I love it.
@jane
I'm at a loss for words. This is amazing. I love it.
@jenny
I'm at a loss for words. This is amazing. I love it.
@james
I'm at a loss for words. This is amazing. I love it.
@jane
I'm at a loss for words. This is amazing. I love it.
@jenny
I'm at a loss for words. This is amazing. I love it.
@james
I'm at a loss for words. This is amazing. I love it.
<script lang="ts"> import Marquee from "$lib/components/magic/marquee/marquee.svelte"; import ReviewCard from "./review-card.svelte";
let reviews = $state([ { name: "Jack", username: "@jack", body: "I've never seen anything like this before. It's amazing. I love it.", img: "https://avatar.vercel.sh/jack", }, { name: "Jill", username: "@jill", body: "I don't know what to say. I'm speechless. This is amazing.", img: "https://avatar.vercel.sh/jill", }, { name: "John", username: "@john", body: "I'm at a loss for words. This is amazing. I love it.", img: "https://avatar.vercel.sh/john", }, { name: "Jane", username: "@jane", body: "I'm at a loss for words. This is amazing. I love it.", img: "https://avatar.vercel.sh/jane", }, { name: "Jenny", username: "@jenny", body: "I'm at a loss for words. This is amazing. I love it.", img: "https://avatar.vercel.sh/jenny", }, { name: "James", username: "@james", body: "I'm at a loss for words. This is amazing. I love it.", img: "https://avatar.vercel.sh/james", }, ]);
let firstRow = $derived(reviews.slice(0, reviews.length / 2)); let secondRow = $derived(reviews.slice(reviews.length / 2));</script>
<div class="relative flex w-full flex-col items-center justify-center overflow-hidden"> <Marquee pauseOnHover class="[--duration:20s]"> {#each firstRow as review} <ReviewCard {...review} /> {/each} </Marquee> <Marquee reverse pauseOnHover class="[--duration:20s]"> {#each secondRow as review} <ReviewCard {...review} /> {/each} </Marquee> <div class="from-background pointer-events-none absolute inset-y-0 left-0 w-1/4 bg-gradient-to-r" ></div> <div class="from-background pointer-events-none absolute inset-y-0 right-0 w-1/4 bg-gradient-to-l" ></div></div>Installation
Copy the Source Code
Copy and paste the following code into your project:
<script lang="ts"> import type { ClassValue } from "svelte/elements"; import { cn } from "#lib/utils.js"; import type { Snippet } from "svelte";
interface MarqueeProps { children: Snippet; class?: ClassValue; reverse?: boolean; pauseOnHover?: boolean; vertical?: boolean; repeat?: number; [key: string]: any; }
let { children, class: className = "", reverse = false, pauseOnHover = false, vertical = false, repeat = 4, ...rest }: MarqueeProps = $props();</script>
<div {...rest} class={cn( "group flex gap-(--gap) overflow-hidden p-2 [--duration:40s] [--gap:1rem]", { "flex-row": !vertical, "flex-col": vertical, }, className )}> {#each Array(repeat).fill(0) as _, i (i)} <div class={cn("flex shrink-0 justify-around gap-(--gap)", { "animate-marquee flex-row": !vertical, "animate-marquee-vertical flex-col": vertical, "group-hover:paused": pauseOnHover, "direction-[reverse]": reverse, })} > {@render children?.()} </div> {/each}</div> import Marquee from "./marquee.svelte";export { Marquee };Add Tailwind CSS
Add the following to your routes/layout.css file:
@theme inline { --animate-marquee: marquee var(--duration) infinite linear; --animate-marquee-vertical: marquee-vertical var(--duration) linear infinite;
@keyframes marquee { from { transform: translateX(0); } to { transform: translateX(calc(-100% - var(--gap))); } } @keyframes marquee-vertical { from { transform: translateY(0); } to { transform: translateY(calc(-100% - var(--gap))); } }}Folder Structure
src/└── lib/ └── components/ └── magic/ └── marquee/ ├── marquee.svelte └── index.tsInstall and integrate the Svelte component documented below.https://sv-animations.vercel.app/magic/docs/components/marquee/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 { Marquee } from "#lib/components/magic/marquee/index.js";</script>
<Marquee> <span>Design</span> <span>Develop</span> <span>Ship</span></Marquee>Examples
Vertical Marquee
A marquee that scrolls vertically.
@jack
I've never seen anything like this before. It's amazing. I love it.
@jill
I don't know what to say. I'm speechless. This is amazing.
@john
I'm at a loss for words. This is amazing. I love it.
@jack
I've never seen anything like this before. It's amazing. I love it.
@jill
I don't know what to say. I'm speechless. This is amazing.
@john
I'm at a loss for words. This is amazing. I love it.
@jack
I've never seen anything like this before. It's amazing. I love it.
@jill
I don't know what to say. I'm speechless. This is amazing.
@john
I'm at a loss for words. This is amazing. I love it.
@jack
I've never seen anything like this before. It's amazing. I love it.
@jill
I don't know what to say. I'm speechless. This is amazing.
@john
I'm at a loss for words. This is amazing. I love it.
@jane
I'm at a loss for words. This is amazing. I love it.
@jenny
I'm at a loss for words. This is amazing. I love it.
@james
I'm at a loss for words. This is amazing. I love it.
@jane
I'm at a loss for words. This is amazing. I love it.
@jenny
I'm at a loss for words. This is amazing. I love it.
@james
I'm at a loss for words. This is amazing. I love it.
@jane
I'm at a loss for words. This is amazing. I love it.
@jenny
I'm at a loss for words. This is amazing. I love it.
@james
I'm at a loss for words. This is amazing. I love it.
@jane
I'm at a loss for words. This is amazing. I love it.
@jenny
I'm at a loss for words. This is amazing. I love it.
@james
I'm at a loss for words. This is amazing. I love it.
<script lang="ts"> import Marquee from "#lib/components/magic/marquee/marquee.svelte"; import ReviewCard from "./review-card.svelte";
let reviews = $state([ { name: "Jack", username: "@jack", body: "I've never seen anything like this before. It's amazing. I love it.", img: "https://avatar.vercel.sh/jack", }, { name: "Jill", username: "@jill", body: "I don't know what to say. I'm speechless. This is amazing.", img: "https://avatar.vercel.sh/jill", }, { name: "John", username: "@john", body: "I'm at a loss for words. This is amazing. I love it.", img: "https://avatar.vercel.sh/john", }, { name: "Jane", username: "@jane", body: "I'm at a loss for words. This is amazing. I love it.", img: "https://avatar.vercel.sh/jane", }, { name: "Jenny", username: "@jenny", body: "I'm at a loss for words. This is amazing. I love it.", img: "https://avatar.vercel.sh/jenny", }, { name: "James", username: "@james", body: "I'm at a loss for words. This is amazing. I love it.", img: "https://avatar.vercel.sh/james", }, ]);
let firstRow = $derived(reviews.slice(0, reviews.length / 2)); let secondRow = $derived(reviews.slice(reviews.length / 2));</script>
<div class="relative flex h-125 w-full flex-row items-center justify-center overflow-hidden"> <Marquee pauseOnHover vertical class="[--duration:20s]"> {#each firstRow as review} <ReviewCard {...review} /> {/each} </Marquee> <Marquee reverse pauseOnHover vertical class="[--duration:20s]"> {#each secondRow as review} <ReviewCard {...review} /> {/each} </Marquee> <div class="from-background pointer-events-none absolute inset-x-0 top-0 h-1/4 bg-linear-to-b" ></div> <div class="from-background pointer-events-none absolute inset-x-0 bottom-0 h-1/4 bg-linear-to-t" ></div></div>3D Marquee
A marquee with a 3D effect.
@jack
I've never seen anything like this before. It's amazing. I love it.
@jill
I don't know what to say. I'm speechless. This is amazing.
@john
I'm at a loss for words. This is amazing. I love it.
@jack
I've never seen anything like this before. It's amazing. I love it.
@jill
I don't know what to say. I'm speechless. This is amazing.
@john
I'm at a loss for words. This is amazing. I love it.
@jack
I've never seen anything like this before. It's amazing. I love it.
@jill
I don't know what to say. I'm speechless. This is amazing.
@john
I'm at a loss for words. This is amazing. I love it.
@jack
I've never seen anything like this before. It's amazing. I love it.
@jill
I don't know what to say. I'm speechless. This is amazing.
@john
I'm at a loss for words. This is amazing. I love it.
@jane
I'm at a loss for words. This is amazing. I love it.
@jenny
I'm at a loss for words. This is amazing. I love it.
@james
I'm at a loss for words. This is amazing. I love it.
@jane
I'm at a loss for words. This is amazing. I love it.
@jenny
I'm at a loss for words. This is amazing. I love it.
@james
I'm at a loss for words. This is amazing. I love it.
@jane
I'm at a loss for words. This is amazing. I love it.
@jenny
I'm at a loss for words. This is amazing. I love it.
@james
I'm at a loss for words. This is amazing. I love it.
@jane
I'm at a loss for words. This is amazing. I love it.
@jenny
I'm at a loss for words. This is amazing. I love it.
@james
I'm at a loss for words. This is amazing. I love it.
@jack
I've never seen anything like this before. It's amazing. I love it.
@jill
I don't know what to say. I'm speechless. This is amazing.
@john
I'm at a loss for words. This is amazing. I love it.
@jack
I've never seen anything like this before. It's amazing. I love it.
@jill
I don't know what to say. I'm speechless. This is amazing.
@john
I'm at a loss for words. This is amazing. I love it.
@jack
I've never seen anything like this before. It's amazing. I love it.
@jill
I don't know what to say. I'm speechless. This is amazing.
@john
I'm at a loss for words. This is amazing. I love it.
@jack
I've never seen anything like this before. It's amazing. I love it.
@jill
I don't know what to say. I'm speechless. This is amazing.
@john
I'm at a loss for words. This is amazing. I love it.
@jane
I'm at a loss for words. This is amazing. I love it.
@jenny
I'm at a loss for words. This is amazing. I love it.
@james
I'm at a loss for words. This is amazing. I love it.
@jane
I'm at a loss for words. This is amazing. I love it.
@jenny
I'm at a loss for words. This is amazing. I love it.
@james
I'm at a loss for words. This is amazing. I love it.
@jane
I'm at a loss for words. This is amazing. I love it.
@jenny
I'm at a loss for words. This is amazing. I love it.
@james
I'm at a loss for words. This is amazing. I love it.
@jane
I'm at a loss for words. This is amazing. I love it.
@jenny
I'm at a loss for words. This is amazing. I love it.
@james
I'm at a loss for words. This is amazing. I love it.
<script lang="ts"> import Marquee from "#lib/components/magic/marquee/marquee.svelte"; import ReviewCard from "./review-card.svelte";
let reviews = $state([ { name: "Jack", username: "@jack", body: "I've never seen anything like this before. It's amazing. I love it.", img: "https://avatar.vercel.sh/jack", }, { name: "Jill", username: "@jill", body: "I don't know what to say. I'm speechless. This is amazing.", img: "https://avatar.vercel.sh/jill", }, { name: "John", username: "@john", body: "I'm at a loss for words. This is amazing. I love it.", img: "https://avatar.vercel.sh/john", }, { name: "Jane", username: "@jane", body: "I'm at a loss for words. This is amazing. I love it.", img: "https://avatar.vercel.sh/jane", }, { name: "Jenny", username: "@jenny", body: "I'm at a loss for words. This is amazing. I love it.", img: "https://avatar.vercel.sh/jenny", }, { name: "James", username: "@james", body: "I'm at a loss for words. This is amazing. I love it.", img: "https://avatar.vercel.sh/james", }, ]);
let firstRow = $derived(reviews.slice(0, reviews.length / 2)); let secondRow = $derived(reviews.slice(reviews.length / 2)); let thirdRow = $derived(reviews.slice(0, reviews.length / 2)); let fourthRow = $derived(reviews.slice(reviews.length / 2));</script>
<div class="relative flex h-96 w-full flex-row items-center justify-center gap-4 overflow-hidden perspective-near"> <div class="flex flex-row items-center gap-4" style="transform:translateX(-100px) translateY(0px) translateZ(-100px) rotateX(20deg) rotateY(-10deg) rotateZ(20deg);" > <Marquee pauseOnHover vertical class="[--duration:20s]"> {#each firstRow as review} <ReviewCard {...review} /> {/each} </Marquee> <Marquee reverse pauseOnHover class="[--duration:20s]" vertical> {#each secondRow as review} <ReviewCard {...review} /> {/each} </Marquee> <Marquee reverse pauseOnHover class="[--duration:20s]" vertical> {#each thirdRow as review} <ReviewCard {...review} /> {/each} </Marquee> <Marquee pauseOnHover class="[--duration:20s]" vertical> {#each fourthRow as review} <ReviewCard {...review} /> {/each} </Marquee> </div> <div class="from-background pointer-events-none absolute inset-x-0 top-0 h-1/4 bg-linear-to-b" ></div> <div class="from-background pointer-events-none absolute inset-x-0 bottom-0 h-1/4 bg-linear-to-t" ></div> <div class="from-background pointer-events-none absolute inset-y-0 left-0 w-1/4 bg-linear-to-r" ></div> <div class="from-background pointer-events-none absolute inset-y-0 right-0 w-1/4 bg-linear-to-l" ></div></div>Props
Marquee
An infinite scrolling component that can be used to display text, images, or videos.
| Name | Type | Default | Description |
|---|---|---|---|
children | Snippet | - | The content to scroll inside the marquee |
class | ClassValue | "" | Additional CSS classes to apply |
reverse | boolean | false | Reverse the animation direction |
pauseOnHover | boolean | false | Pause the animation when hovered |
vertical | boolean | false | Scroll vertically instead of horizontally |
repeat | number | 4 | Number of times to repeat the content for seamless scrolling |