Infinite marquee
Endless scrolling rows of words or logos with soft faded edges, opposite directions and pause-on-hover.
import type { ReactNode } from "react";
import "./marquee.css";
type MarqueeProps = {
items: ReactNode[];
/** Seconds for one full loop. Bigger = slower. */
duration?: number;
reverse?: boolean;
/** Accessible name for the row, e.g. "Featured clients". */
label: string;
};
/**
* Marquee
* Pure CSS: the list is rendered twice side by side and the track slides by
* exactly half its width, so the loop is seamless. No JavaScript runs.
*/
export function Marquee({
items,
duration = 30,
reverse = false,
label,
}: MarqueeProps) {
const list = (hidden: boolean) => (
<ul className="gu-marquee__list" aria-hidden={hidden || undefined}>
{items.map((item, i) => (
<li key={i} className="gu-marquee__item">
{item}
</li>
))}
</ul>
);
return (
<section
className="gu-marquee"
aria-label={label}
data-reverse={reverse || undefined}
style={{ ["--duration" as string]: `${duration}s` }}
>
<div className="gu-marquee__track">
{list(false)}
{list(true)}
</div>
</section>
);
}
Paste this into ChatGPT, Claude, Cursor, v0, Lovable or Bolt. It describes the layout, motion, colors and accessibility and includes the code, so the AI can rebuild it in any framework.
# Build this UI piece: Infinite marquee
You are a senior front-end engineer. Recreate the piece below in my project. If I don't say which framework I use, ask once, then build it in that framework (React, Vue, Svelte, Angular, Astro, plain HTML/CSS/JS or anything else). Keep the behavior, motion, colors, spacing and accessibility exactly as described. Keep the code clean and commented for beginners.
## What it is
Endless horizontal marquee rows (text, logos or chips) with faded edges. Rows can run in opposite directions and pause when hovered, focused or pressed.
## Layout and look
- Container: overflow hidden, mask-image linear-gradient(90deg, transparent, black 12%, black 88%, transparent) for soft edges.
- Track: display flex, width max-content. Inside, the same list is rendered twice; the second copy is aria-hidden.
- Items: gap 2.5rem, no wrapping, vertically centered.
- Demo row 1: huge black-weight words (clamp(2rem, 6vw, 4rem), letter-spacing -0.04em) separated by an orange ✺ (#ff5a1f).
- Demo row 2: orange pills (#ff5a1f background, #0e0e10 bold text, 0.6rem × 1.2rem padding).
## Behavior and motion
- CSS only: keyframes translateX(0 → -50%), linear, infinite, duration set by a --duration variable (default 30s). Reverse rows use animation-direction: reverse.
- Pause with animation-play-state: paused on :hover, :focus-within and :active (press-and-hold on touch).
## Accessibility
- The row is a <section> with an aria-label (e.g. "Featured clients"). Only the first copy is read.
- prefers-reduced-motion: stop the animation, remove the edge mask, hide the duplicate copy and let the row scroll horizontally.
## Props
items (array of nodes), duration (seconds), reverse (boolean), label (string).
## Reference implementation
The original is written in React with one plain CSS file. Dependencies: none (plain React and CSS). Translate it faithfully; do not add new libraries unless my framework needs them.
### Marquee.tsx
```tsx
import type { ReactNode } from "react";
import "./marquee.css";
type MarqueeProps = {
items: ReactNode[];
/** Seconds for one full loop. Bigger = slower. */
duration?: number;
reverse?: boolean;
/** Accessible name for the row, e.g. "Featured clients". */
label: string;
};
/**
* Marquee
* Pure CSS: the list is rendered twice side by side and the track slides by
* exactly half its width, so the loop is seamless. No JavaScript runs.
*/
export function Marquee({
items,
duration = 30,
reverse = false,
label,
}: MarqueeProps) {
const list = (hidden: boolean) => (
<ul className="gu-marquee__list" aria-hidden={hidden || undefined}>
{items.map((item, i) => (
<li key={i} className="gu-marquee__item">
{item}
</li>
))}
</ul>
);
return (
<section
className="gu-marquee"
aria-label={label}
data-reverse={reverse || undefined}
style={{ ["--duration" as string]: `${duration}s` }}
>
<div className="gu-marquee__track">
{list(false)}
{list(true)}
</div>
</section>
);
}
```
### marquee.css
```css
.gu-marquee {
--gap: 2.5rem;
overflow: hidden;
/* Fade the left and right edges. */
mask-image: linear-gradient(
90deg,
transparent,
#000 12%,
#000 88%,
transparent
);
-webkit-mask-image: linear-gradient(
90deg,
transparent,
#000 12%,
#000 88%,
transparent
);
}
.gu-marquee__track {
display: flex;
width: max-content;
animation: gu-marquee var(--duration, 30s) linear infinite;
}
.gu-marquee[data-reverse] .gu-marquee__track {
animation-direction: reverse;
}
/* Pause on hover, keyboard focus, or press-and-hold on touch. */
.gu-marquee:hover .gu-marquee__track,
.gu-marquee:focus-within .gu-marquee__track,
.gu-marquee:active .gu-marquee__track {
animation-play-state: paused;
}
.gu-marquee__list {
display: flex;
flex-shrink: 0;
gap: var(--gap);
margin: 0;
padding: 0 calc(var(--gap) / 2);
list-style: none;
}
.gu-marquee__item {
display: flex;
align-items: center;
white-space: nowrap;
}
@keyframes gu-marquee {
to {
transform: translateX(-50%);
}
}
@media (prefers-reduced-motion: reduce) {
.gu-marquee {
overflow-x: auto;
mask-image: none;
-webkit-mask-image: none;
}
.gu-marquee__track {
animation: none;
}
.gu-marquee__list[aria-hidden] {
display: none;
}
}
```
You might also want
Next piece: Text scrambleLetter scatter headline
Animations, beginner
Scroll-speed marquee
Animations, intermediate
Text scramble
Animations, beginner