Skip to content

strip · HTML and CSS

Marquee

An endless strip of names, logos or words that pauses when someone hovers, focuses or asks it to.

Infinite marquee with inert duplicate, hover/focus pause, and pause button

  • HTML and CSS
  • Reduced motion: static
  • 2.45 KB gzip
  • Layout shift 0
View the source Spec sheet as Markdown

Install

Install
pnpm dlx shadcn@4.21.1 add @frictionborn/marquee

Playground

Your code
import { Marquee } from "@/components/ui/marquee";

<Marquee>
  <span>noise-field</span>
  <span>mesh-gradient</span>
  <span>particle-field</span>
</Marquee>

In a full example

The full example loads as you scroll to it.

Accessibility

  • The duplicate copy is aria-hidden and inert so screen readers and keyboard users encounter each element once. A built-in pause/play button is shown unless showPauseButton is false or reduced motion is set.
  • Keyboard: Focus inside the marquee pauses it when pauseOnFocus is true; duplicate items are inert so each item is tabbed once
  • Touch: No touch-specific behaviour; the animation runs on touch devices unless reduced motion is set
  • WCAG criteria it is built for: 2.2.2

Props

PropTypeDefaultWhat it does
childrenReact.ReactNodenoneRequired. Content elements repeated across the strip (rendered twice; avoid fixed ids).
pixelsPerSecondnumber40Transit rate in physical pixels per second (default 40). speed multiplies it. The cycle is never shorter than 5 s.
speednumber1Unitless multiplier on pixelsPerSecond (1 = as given, 0.5 = half, 2 = double).
pausedbooleanfalseUniversal pause prop. Freezes ticker transit.
noncestringnoneOptional CSP nonce forwarded to internal scoped <style> element.
direction"left" | "right""left"Scroll direction of the ticker.
pauseOnHoverbooleantrueFreezes scroll transit while the pointer hovers over the strip.
pauseOnFocusbooleantrueFreezes scroll transit while any element inside the strip holds keyboard focus.
showPauseButtonbooleantrueRenders a pause/play button (not rendered under reduced motion). Keep it for marquees that run longer than 5 s.
gapstring | number"2rem"Spacing between items (a number is treated as px).
classNamestring""CSS classes applied to the outer container (the built-in class fb-marquee is kept).
styleReact.CSSPropertiesnoneOptional. No default. Inline styles on the outer container, merged last (consumer wins).
refReact.Ref<HTMLDivElement>noneReceives the root <div>.
maxTiernumber3Hard ceiling on the capability tier.

Measured on the bench

Measured by the automated bench at commit 801163e on 2026-10-21. These numbers are written by the bench, never by hand.

MeasureResult
Size, gzip2.45 KB at load, 0.02 KB loaded later
Layout shift0
Frames when nothing should moveoff screen 0, hidden tab 0, reduced motion 0
axe accessibility scan0 serious, 0 critical

Browsers it ran in

Automated Playwright runs, some with device emulation. Results from physical phones and tablets are still pending, so none are listed.

EnvironmentTierResultDateNotes
Chromium Desktop (SwiftShader)3pass2026-10-2119 passed, 0 failed
Chromium Mobile (Pixel 7 emulation)2pass2026-10-2117 passed, 0 failed
Firefox Desktop3pass2026-10-2118 passed, 0 failed
WebKit Desktop3pass2026-10-2118 passed, 0 failed
WebKit Mobile (iPhone 14 emulation)2pass2026-10-2117 passed, 0 failed

On different devices

Reduced motion (static): The animation does not run: the track is rendered static (not animated), with no duplicate copy and no pause button.

TierWhat it does
T3 FullSame as tier 2
T2 StandardCSS marquee animation with hover/focus pause, width-based duration calibration and the pause button
T1 LiteCSS marquee animation; same behaviour as tiers 2 and 3 (speed does not vary by tier)
T0 StaticAnimation paused and no duplicate copy rendered; the track is a static row, not animated (server render, prefers-reduced-motion, Save-Data, or no WebGL2)

Content Security Policy

  • Works without 'unsafe-eval'.
  • Uses the reveal gate ([data-motion="ok"]): render <MotionReadyScript /> in <head> (with your nonce), or call initMotionReady() in Vite.
  • Sets inline style attributes, so allow style-src-attr 'unsafe-inline'.

Goes well with