An endless ticker for logos, tags or news. It is a server component: the content is rendered several times and the track moves by one copy with a CSS animation. The only client code is a tiny helper that eases the speed to zero on hover and focus. Edges fade out with a mask, copies are hidden from screen readers.
Browser Support
Removes inactive content from interaction
Pauses movement while focused
Creates fading edges
Preview
Hover the ticker, it slows down smoothly and speeds up when you leave.
Installation
Usage
import { Marquee } from "@/components/ui/marquee"
export default function Example() {
return (
<Marquee duration={20} pauseOnHover>
<img src="/logos/one.svg" alt="One" className="h-8" />
<img src="/logos/two.svg" alt="Two" className="h-8" />
<img src="/logos/three.svg" alt="Three" className="h-8" />
</Marquee>
)
}Examples
Two rows in opposite directions
reverse flips the direction. Each row has its own duration and gap. The rows are short, so repeat renders four copies.
<Marquee duration={12} repeat={4} gap={16}>{tags}</Marquee>
<Marquee duration={8} repeat={4} gap={16} reverse>{moreTags}</Marquee>Vertical
vertical scrolls the items upwards. Give the marquee a fixed height.
<Marquee vertical duration={14} gap={12} pauseOnHover className="h-56 w-64">
{updates.map((text) => (
<div key={text} className="rounded-lg border bg-card px-4 py-3 text-sm">
{text}
</div>
))}
</Marquee>Few items
CSS cannot measure the content, so the number of copies is set by repeat. One copy times repeat minus one must cover the container, otherwise a gap appears at the end of the loop.
<Marquee repeat={8} gap={48}>
<Logo name="Orbitly" />
<Logo name="Squarely" />
</Marquee>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| children | ReactNode | - | Items of the ticker |
| duration | number | 20 | Seconds for one copy of the content to scroll past |
| repeat | number | 2 | How many copies to render. Raise it when the content is narrower than the container |
| reverse | boolean | false | Move right (or down) instead of left (or up) |
| vertical | boolean | false | Scroll vertically. Needs a fixed height |
| pauseOnHover | boolean | false | Slow down to a stop while hovered |
| stopDuration | number | 500 | Milliseconds to slow down on hover or focus and to speed up again |
| gap | number | string | 32 | Space between items: number in px or any CSS length |
| fade | number | 48 | Width of the faded edges in px, 0 turns the mask off |
| className | string | - | Additional CSS classes |
| ...props | ComponentProps<"div"> | - | Any other div attributes |
Features
- Almost no JavaScript: the ticker is a Server Component, about 60 lines of client code brake it smoothly; without scripts it still runs and pauses at once
- Accessible: copies get aria-hidden and inert, the ticker slows to a stop while focus is inside
- Reduced motion: with prefers-reduced-motion the ticker stops and wraps into rows
- No dependencies: keyframes live inside the component