Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

✨ feat: add marquee component

Dillion Vermaaccf83d05ccc
diff --git a/app/(marketing)/layout.tsx b/app/(marketing)/layout.tsx
index 28e38307..84d47ef0 100644
--- a/app/(marketing)/layout.tsx
+++ b/app/(marketing)/layout.tsx
@@ -15,7 +15,7 @@ export default async function MarketingLayout({
<div className="flex min-h-screen flex-col">
<SiteHeader user={user} />
<main className="flex-1">
- <div className="pointer-events-none h-screen absolute inset-0 bg-[radial-gradient(ellipse_80%_50%_at_50%_-20%,rgba(120,119,198,0.5),rgba(255,255,255,0))]" />
+ <div className="pointer-events-none h-screen absolute inset-0 dark:bg-[radial-gradient(ellipse_80%_50%_at_50%_-20%,rgba(120,119,198,0.5),rgba(255,255,255,0))]" />
{children}
</main>
<SiteFooter />
diff --git a/content/components/marquee.mdx b/content/components/marquee.mdx
new file mode 100644
index 00000000..3eb94843
--- /dev/null
+++ b/content/components/marquee.mdx
@@ -0,0 +1,85 @@
+---
+title: Marquee
+date: 2023-07-21
+summary: An infinite scrolling component that can be used to display text, images, or videos.
+author: dillionverma
+published: true
+video: https://cdn.magicuikit.com/marquee.mp4
+# toc: false
+---
+
+<ComponentPreview name="marquee-demo" />
+
+<Steps>
+
+<Step>
+
+## Prerequisites
+
+```bash
+npm install -D tailwindcss clsx tailwind-merge
+```
+
+Copy and page the following code into your project.
+
+```typescript
+// lib/utils.ts
+import clsx, { ClassValue } from "clsx";
+import { twMerge } from "tailwind-merge";
+
+export function cn(...inputs: ClassValue[]) {
+ return twMerge(clsx(inputs));
+}
+```
+
+```js
+// tailwind.config.js
+module.exports = {
+ theme: {
+ extend: {
+ animation: {
+ marquee: "marquee 20s linear infinite",
+ },
+ keyframes: {
+ marquee: {
+ from: { transform: "translateX(0)" },
+ to: { transform: "translateX(calc(-50% - var(--gap)/2))" },
+ },
+ },
+ },
+ },
+};
+```
+
+</Step>
+
+<Step>
+
+## Installation
+
+Copy and page the following code into your project.
+
+```text
+components/magicui/marquee.tsx
+```
+
+<ComponentSource name="marquee" />
+
+</Step>
+
+</Steps>
+
+## Examples
+
+### Logos
+
+<ComponentPreview name="marquee-logos" />
+
+## Props
+
+| Prop | Type | Default | Description |
+| ------------ | ------- | ------- | ---------------------------------------------------------------------------- |
+| className | string | | The class name to apply to the component. |
+| reverse | boolean | false | Whether or not to reverse the direction of the marquee. |
+| pauseOnHover | boolean | false | Whether or not to pause the marquee when the user hovers over the component. |
+| children | node | | The content to display in the marquee. |
diff --git a/content/components/temp.mdx b/content/components/temp.mdx
new file mode 100644
index 00000000..e4bc0a77
--- /dev/null
+++ b/content/components/temp.mdx
@@ -0,0 +1,30 @@
+```tsx
+<div className="absolute bottom-6 left-0 right-0 flex translate-y-4 items-center justify-center opacity-0 duration-500 ease-in-out group-hover:translate-y-0 group-hover:opacity-100 group-focus-visible:translate-y-0 group-focus-visible:opacity-100">
+ <span className="flex items-center gap-1">
+ <span className="text-sm text-slate-11 font-normal">Read more</span>
+ <svg
+ className="text-[#70757E]"
+ width="24"
+ height="24"
+ viewBox="0 0 24 24"
+ fill="none"
+ xmlns="http://www.w3.org/2000/svg"
+ >
+ <path
+ d="M13.75 6.75L19.25 12L13.75 17.25"
+ stroke="currentColor"
+ stroke-width="1.5"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ ></path>
+ <path
+ d="M19 12H4.75"
+ stroke="currentColor"
+ stroke-width="1.5"
+ stroke-linecap="round"
+ stroke-linejoin="round"
+ ></path>
+ </svg>
+ </span>
+</div>
+```
diff --git a/registry/components/example/marquee-demo.tsx b/registry/components/example/marquee-demo.tsx
new file mode 100644
index 00000000..e78cba93
--- /dev/null
+++ b/registry/components/example/marquee-demo.tsx
@@ -0,0 +1,90 @@
+import { cn } from "@/lib/utils";
+import Marquee from "@/registry/components/magicui/marquee";
+
+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",
+ },
+];
+const ReviewCard = ({
+ img,
+ name,
+ username,
+ body,
+}: {
+ img: string;
+ name: string;
+ username: string;
+ body: string;
+}) => {
+ return (
+ <figure
+ className={cn(
+ "w-64 p-4 rounded-xl border cursor-pointer overflow-hidden relative",
+ // light styles
+ "bg-gray-950/[.01] hover:bg-gray-950/[.05] border-gray-950/[.1]",
+ // dark styles
+ "dark:bg-gray-50/[.10] dark:hover:bg-gray-50/[.15] dark:border-gray-50/[.1]"
+ )}
+ >
+ <div className="flex flex-row items-center gap-2">
+ <img className="rounded-full" width="32" height="32" alt="" src={img} />
+ <div className="flex flex-col">
+ <figcaption className="font-medium dark:text-white text-sm">
+ {name}
+ </figcaption>
+ <p className="font-medium dark:text-white/40 text-xs">{username}</p>
+ </div>
+ </div>
+ <blockquote className="mt-2 text-sm">{body}</blockquote>
+ </figure>
+ );
+};
+
+const MarqueeDemo = () => {
+ return (
+ <div className="border rounded-lg h-full w-full relative flex justify-center items-center bg-background overflow-hidden py-20 flex-col gap-4">
+ <Marquee pauseOnHover>
+ {reviews.map((review) => (
+ <ReviewCard key={review.username} {...review} />
+ ))}
+ </Marquee>
+ <Marquee reverse pauseOnHover>
+ {reviews.map((review) => (
+ <ReviewCard key={review.username} {...review} />
+ ))}
+ </Marquee>
+ <div className="pointer-events-none absolute inset-y-0 left-0 w-1/3 bg-gradient-to-r dark:from-gray-950 from-gray-50"></div>
+ <div className="pointer-events-none absolute inset-y-0 right-0 w-1/3 bg-gradient-to-l dark:from-gray-950 from-gray-50"></div>
+ </div>
+ );
+};
+
+export default MarqueeDemo;
diff --git a/registry/components/example/marquee-logos.tsx b/registry/components/example/marquee-logos.tsx
new file mode 100644
index 00000000..7d15e1a9
--- /dev/null
+++ b/registry/components/example/marquee-logos.tsx
@@ -0,0 +1,53 @@
+import { cn } from "@/lib/utils";
+import Marquee from "@/registry/components/magicui/marquee";
+
+const logos = [
+ {
+ name: "Microsoft",
+ img: "https://cdn.simpleicons.org/microsoft/000/fff",
+ },
+ {
+ name: "Apple",
+ img: "https://cdn.simpleicons.org/apple/000/fff",
+ },
+ {
+ name: "Google",
+ img: "https://cdn.simpleicons.org/google/000/fff",
+ },
+ {
+ name: "Facebook",
+ img: "https://cdn.simpleicons.org/facebook/000/fff",
+ },
+ {
+ name: "LinkedIn",
+ img: "https://cdn.simpleicons.org/linkedin/000/fff",
+ },
+ {
+ name: "Twitter",
+ img: "https://cdn.simpleicons.org/twitter/000/fff",
+ },
+];
+
+const Logo = ({ name, img }: { name: string; img: string }) => {
+ return (
+ <div className={cn("h-12 w-12 cursor-pointer")}>
+ <img src={img} alt={name} />
+ </div>
+ );
+};
+
+const MarqueeLogos = () => {
+ return (
+ <div className="border rounded-lg h-full w-full relative flex justify-center items-center bg-background overflow-hidden py-20 flex-col gap-4">
+ <Marquee className="[--gap:3rem]">
+ {logos.map((logo, idx) => (
+ <Logo key={idx} {...logo} />
+ ))}
+ </Marquee>
+ <div className="pointer-events-none absolute inset-y-0 left-0 w-1/3 bg-gradient-to-r dark:from-gray-950 from-gray-50"></div>
+ <div className="pointer-events-none absolute inset-y-0 right-0 w-1/3 bg-gradient-to-l dark:from-gray-950 from-gray-50"></div>
+ </div>
+ );
+};
+
+export default MarqueeLogos;
diff --git a/registry/components/magicui/marquee.tsx b/registry/components/magicui/marquee.tsx
new file mode 100644
index 00000000..5f80fded
--- /dev/null
+++ b/registry/components/magicui/marquee.tsx
@@ -0,0 +1,40 @@
+import { cn } from "@/lib/utils";
+import { Children, cloneElement } from "react";
+
+interface MarqueeProps {
+ className?: string;
+ reverse?: boolean;
+ pauseOnHover?: boolean;
+ children?: React.ReactNode;
+ [key: string]: any;
+}
+
+const Marquee = ({
+ className,
+ reverse,
+ pauseOnHover = false,
+ children,
+ ...props
+}: MarqueeProps) => {
+ return (
+ <div
+ {...props}
+ className={cn(
+ "relative flex w-full overflow-hidden [--gap:1rem]",
+ className
+ )}
+ >
+ <div
+ className={cn("animate-marquee flex items-stretch w-max gap-[--gap]", {
+ "[animation-direction:reverse]": reverse,
+ "hover:[animation-play-state:paused]": pauseOnHover,
+ })}
+ >
+ {Children.map(children, (child) => cloneElement(child as any))}
+ {Children.map(children, (child) => cloneElement(child as any))}
+ </div>
+ </div>
+ );
+};
+
+export default Marquee;
diff --git a/registry/index.tsx b/registry/index.tsx
index a7ce164e..0d54a74e 100644
--- a/registry/index.tsx
+++ b/registry/index.tsx
@@ -32,6 +32,11 @@ const ui: Registry = {
type: "components:ui",
files: ["registry/components/magicui/dot-pattern.tsx"],
},
+ marquee: {
+ name: "marquee",
+ type: "components:ui",
+ files: ["registry/components/magicui/marquee.tsx"],
+ },
};
const example: Registry = {
@@ -107,6 +112,22 @@ const example: Registry = {
() => import("@/registry/components/example/dot-pattern-linear-gradient")
),
},
+ "marquee-demo": {
+ name: "marquee-demo",
+ type: "components:example",
+ files: ["registry/components/example/marquee-demo.tsx"],
+ component: React.lazy(
+ () => import("@/registry/components/example/marquee-demo")
+ ),
+ },
+ "marquee-logos": {
+ name: "marquee-logos",
+ type: "components:example",
+ files: ["registry/components/example/marquee-logos.tsx"],
+ component: React.lazy(
+ () => import("@/registry/components/example/marquee-logos")
+ ),
+ },
};
export const registry: Registry = {
diff --git a/tailwind.config.ts b/tailwind.config.ts
index 467ca9d5..9a3e42c8 100644
--- a/tailwind.config.ts
+++ b/tailwind.config.ts
@@ -66,6 +66,7 @@ module.exports = {
gradient: "gradient 8s linear infinite",
meteor: "meteor 5s linear infinite",
grid: "grid 15s linear infinite",
+ marquee: "marquee 20s linear infinite",
},
keyframes: {
"accordion-down": {
@@ -93,6 +94,10 @@ module.exports = {
"0%": { transform: "rotateX(45deg) translateY(-50%)" },
"100%": { transform: "rotateX(45deg) translateY(0)" },
},
+ marquee: {
+ from: { transform: "translateX(0)" },
+ to: { transform: "translateX(calc(-50% - var(--gap)/2))" },
+ },
},
},
},