# Marquee

> A seamless infinite scroller for logos and testimonials that pauses on hover.

Category: Layout · Free · Updated 2026-10-20 · Live demo: https://www.motionkitui.com/components/marquee

## When to use it

Customer logo bands, testimonial strips, tech stacks and announcement tickers.

## How it works

The track holds two copies of your content and moves left at a steady number of pixels per second. Wrapping at exactly half its width makes the loop seamless. It pauses on hover and when keyboard focus moves into a link inside, and an optional mask fades the edges.

## Installation

```bash
npx shadcn@latest add https://www.motionkitui.com/r/marquee.json
```

Or copy `components/motionkit/marquee.tsx` below. Requires react, motion and Tailwind CSS v4. Free for personal projects; commercial use needs MotionKit Plus (https://www.motionkitui.com/pricing).

## Props

| Prop | Type | Default | Description |
| --- | --- | --- | --- |
| `speed` | `number` | `50` | Pixels per second. |
| `direction` | `"left" \| "right"` | `"left"` | Scroll direction. |
| `pauseOnHover` | `boolean` | `true` | Stop while hovered or while something inside has keyboard focus. |
| `fade` | `boolean` | `true` | Fade the left and right edges. |

## Accessibility

- **Keyboard: Partial.** Pauses when anything inside gets keyboard focus. The duplicate copy is hidden, so links are not reached twice. There is no built-in pause button.
- **Screen readers: Pass.** The second copy that makes the loop seamless is hidden from assistive tech.
- **Reduced motion: Partial.** Stops completely for reduced-motion users, and pauses on hover and focus. It loops forever otherwise, so if it sits beside other content for more than 5 seconds, WCAG 2.2.2 asks you to add a pause control.
- **Colour contrast: Not applicable.** Uses whatever colours your items have.

## Source

```tsx
"use client";

import { useRef, useState, type ReactNode } from "react";
import { motion, useAnimationFrame, useMotionValue, useReducedMotion } from "motion/react";

type MarqueeProps = {
  children: ReactNode;
  /** Pixels per second. */
  speed?: number;
  direction?: "left" | "right";
  /** Stop while hovered or while something inside has keyboard focus. */
  pauseOnHover?: boolean;
  /** Fade the left and right edges. */
  fade?: boolean;
  className?: string;
};

export function Marquee({
  children,
  speed = 50,
  direction = "left",
  pauseOnHover = true,
  fade = true,
  className = "",
}: MarqueeProps) {
  const track = useRef<HTMLDivElement>(null);
  const [paused, setPaused] = useState(false);
  const reduceMotion = useReducedMotion();
  const x = useMotionValue(0);

  useAnimationFrame((_, delta) => {
    if (reduceMotion || (pauseOnHover && paused) || !track.current) return;
    // the track holds two copies, so wrapping at half its width loops seamlessly
    const half = track.current.scrollWidth / 2;
    const step = (speed * delta) / 1000;
    let next = x.get() + (direction === "left" ? -step : step);
    if (next <= -half) next += half;
    if (next > 0) next -= half;
    x.set(next);
  });

  return (
    <div
      // keyboard users get the same pause when focus moves into a link or button inside
      onPointerEnter={() => setPaused(true)}
      onPointerLeave={() => setPaused(false)}
      onFocus={() => setPaused(true)}
      onBlur={() => setPaused(false)}
      className={`overflow-hidden ${className}`}
      style={
        fade
          ? { maskImage: "linear-gradient(to right, transparent, black 12%, black 88%, transparent)" }
          : undefined
      }
    >
      <motion.div ref={track} style={{ x }} className="flex w-max">
        <div className="flex shrink-0">{children}</div>
        <div className="flex shrink-0" aria-hidden>
          {children}
        </div>
      </motion.div>
    </div>
  );
}
```
