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
Install
pnpm dlx shadcn@4.21.1 add @frictionborn/marquee
Playground
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
| Prop | Type | Default | What it does |
|---|---|---|---|
children | React.ReactNode | none | Required. Content elements repeated across the strip (rendered twice; avoid fixed ids). |
pixelsPerSecond | number | 40 | Transit rate in physical pixels per second (default 40). speed multiplies it. The cycle is never shorter than 5 s. |
speed | number | 1 | Unitless multiplier on pixelsPerSecond (1 = as given, 0.5 = half, 2 = double). |
paused | boolean | false | Universal pause prop. Freezes ticker transit. |
nonce | string | none | Optional CSP nonce forwarded to internal scoped <style> element. |
direction | "left" | "right" | "left" | Scroll direction of the ticker. |
pauseOnHover | boolean | true | Freezes scroll transit while the pointer hovers over the strip. |
pauseOnFocus | boolean | true | Freezes scroll transit while any element inside the strip holds keyboard focus. |
showPauseButton | boolean | true | Renders a pause/play button (not rendered under reduced motion). Keep it for marquees that run longer than 5 s. |
gap | string | number | "2rem" | Spacing between items (a number is treated as px). |
className | string | "" | CSS classes applied to the outer container (the built-in class fb-marquee is kept). |
style | React.CSSProperties | none | Optional. No default. Inline styles on the outer container, merged last (consumer wins). |
ref | React.Ref<HTMLDivElement> | none | Receives the root <div>. |
maxTier | number | 3 | Hard 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.
| Measure | Result |
|---|---|
| Size, gzip | 2.45 KB at load, 0.02 KB loaded later |
| Layout shift | 0 |
| Frames when nothing should move | off screen 0, hidden tab 0, reduced motion 0 |
| axe accessibility scan | 0 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.
| Environment | Tier | Result | Date | Notes |
|---|---|---|---|---|
| Chromium Desktop (SwiftShader) | 3 | pass | 2026-10-21 | 19 passed, 0 failed |
| Chromium Mobile (Pixel 7 emulation) | 2 | pass | 2026-10-21 | 17 passed, 0 failed |
| Firefox Desktop | 3 | pass | 2026-10-21 | 18 passed, 0 failed |
| WebKit Desktop | 3 | pass | 2026-10-21 | 18 passed, 0 failed |
| WebKit Mobile (iPhone 14 emulation) | 2 | pass | 2026-10-21 | 17 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.
| Tier | What it does |
|---|---|
| T3 Full | Same as tier 2 |
| T2 Standard | CSS marquee animation with hover/focus pause, width-based duration calibration and the pause button |
| T1 Lite | CSS marquee animation; same behaviour as tiers 2 and 3 (speed does not vary by tier) |
| T0 Static | Animation 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 yournonce), or callinitMotionReady()in Vite. - Sets inline
styleattributes, so allowstyle-src-attr 'unsafe-inline'.