Marquee
- Source
- Magic UI ↗
- Author
- Magic UI
- Licence
- MIT
Loading…
Two rows of review cards scroll in opposite directions and pause on hover.
Code
"use client";
import { cn } from "@/lib/utils";
import { Marquee } from "@/lab/magicui/ui/marquee";
import { Fit } from "./fit";
const reviews = [
{ 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" },
];
const firstRow = reviews.slice(0, reviews.length / 2);
const secondRow = reviews.slice(reviews.length / 2);
const ReviewCard = ({ img, name, username, body }: { img: string; name: string; username: string; body: string }) => {
return (
<figure
className={cn(
"relative h-full w-64 cursor-pointer overflow-hidden rounded-xl border p-4 text-neutral-950",
"border-gray-950/[.1] bg-gray-950/[.01] hover:bg-gray-950/[.05]",
"dark:border-gray-50/[.1] dark:bg-gray-50/[.10] dark:hover:bg-gray-50/[.15]",
)}
>
<div className="flex flex-row items-center gap-2">
{/* eslint-disable-next-line @next/next/no-img-element */}
<img className="rounded-full" width="32" height="32" alt="" src={img} />
<div className="flex flex-col">
<figcaption className="text-sm font-medium dark:text-white">{name}</figcaption>
<p className="text-xs font-medium text-neutral-500 dark:text-white/40">{username}</p>
</div>
</div>
<blockquote className="mt-2 text-sm">{body}</blockquote>
</figure>
);
};
export default function MarqueeDemo() {
return (
<Fit width={760} height={320}>
<div className="relative flex h-full w-full flex-col items-center justify-center overflow-hidden">
<Marquee pauseOnHover className="[--duration:20s]">
{firstRow.map((review) => (
<ReviewCard key={review.username} {...review} />
))}
</Marquee>
<Marquee reverse pauseOnHover className="[--duration:20s]">
{secondRow.map((review) => (
<ReviewCard key={review.username} {...review} />
))}
</Marquee>
<div className="pointer-events-none absolute inset-y-0 left-0 w-1/4 bg-gradient-to-r from-[#fbfaf7]"></div>
<div className="pointer-events-none absolute inset-y-0 right-0 w-1/4 bg-gradient-to-l from-[#fbfaf7]"></div>
</div>
</Fit>
);
}
Prompt
Build "Marquee", a layout animation. What it does: Two rows of review cards scroll in opposite directions and pause on hover. Write it as a single self-contained React component in TypeScript that fills its parent (w-full h-full), styled with Tailwind CSS. It sits on a light background, in a 16:10 frame. Respect prefers-reduced-motion with a still state, pause work when the element is off screen, and keep it accessible. Original: https://magicui.design/docs/components/marquee (Magic UI, MIT).