---
title: "Marquee · Base UI — StyleX Blocks"
description: "An infinitely scrolling strip with faded edges that pauses for reduced motion."
url: "https://stylexblocks.com/components/base-ui/marquee/"
agent:
  instructions: "Use this search API to find relevant components and blocks across this site with keywords or natural-language queries, instead of crawling individual pages. Results are returned in Markdown."
  endpoint: "https://stylexblocks.com/.well-known/search?q={query}"
  method: "GET"
  documentation: "https://developers.cloudflare.com/ai-search/how-to/search-for-agents/"
---

# Marquee

An infinitely scrolling strip with faded edges that pauses for reduced motion.

- Behavior engine: Base UI
- Also available for: [Ark UI](https://stylexblocks.com/components/ark-ui/marquee.md), [UI SDK](https://stylexblocks.com/components/ui-sdk/marquee.md)
- Category: Display
- HTML page: https://stylexblocks.com/components/base-ui/marquee/

## Install

Configure the project once (sets the behavior engine and import aliases):

```sh
npx stylexblocks init --style base-ui
```

Then add the item as source you own:

```sh
npx stylexblocks add marquee
```

Equivalent: `npx shadcn add @stylexblocks/marquee`. Registry item JSON: https://stylexblocks.com/r/base-ui/marquee.json

## Usage

```tsx
import { Marquee } from "#components/ui/base-ui/marquee.tsx";

const logos = ["StyleX", "React", "Astro", "Bun", "TypeScript"];

export function Example() {
  return (
    // Content scrolls its children by -50%, so render the items TWICE (the
    // second copy aria-hidden) for a seamless loop; the edges fade the
    // strip and the animation pauses for prefers-reduced-motion. Every part
    // composes via the render prop.
    <Marquee.Root>
      <Marquee.Viewport>
        <Marquee.Content>
          {[0, 1].map((copy) =>
            logos.map((name) => (
              <Chip key={`${name}-${copy}`} aria-hidden={copy === 1 || undefined}>
                {name}
              </Chip>
            )),
          )}
        </Marquee.Content>
      </Marquee.Viewport>
      <Marquee.EdgeStart />
      <Marquee.EdgeEnd />
    </Marquee.Root>
  );
}

// pace and fade are custom properties, overridable per instance:
// <Marquee.Content style={styles.pace}> with { "--marquee-duration": "18s" }
```

## Source

`components/ui/base-ui/marquee.tsx`

```tsx
import * as stylex from "@stylexjs/stylex";
import { createSlotRecipeContext } from "#lib/base-ui/create-slot-recipe-context.tsx";
import { defineSlotRecipe } from "#lib/recipe-props.ts";
import { semanticColors } from '@stylexblocks/ui/semantic-tokens/colors.stylex.ts'

const marqueeRoot = stylex.create({
  base: {
    position: 'relative',
    width: '100%',
    '--marquee-edge-color': semanticColors.bg,
    '--marquee-edge-size': '20%',
  },
})

const marqueeViewport = stylex.create({
  base: {
    overflow: 'hidden',
    display: 'flex',
    width: '100%',
    height: '100%',
  },
})

const marqueeContent = stylex.create({
  base: {
    display: 'flex',
    minWidth: 'max-content',
    animationTimingFunction: 'linear',
    animationFillMode: 'forwards',
    animationDuration: 'var(--marquee-duration)',
    animationDelay: 'var(--marquee-delay)',
    animationIterationCount: 'var(--marquee-loop-count)',
    animationName: {
      default: null,
      '@media (prefers-reduced-motion: reduce)': 'none',
    },
  },
})

const marqueeEdge = stylex.create({
  base: {
    position: 'absolute',
    zIndex: 1,
    pointerEvents: 'none',
  },
})

// The slot recipe ships the timing custom properties (--marquee-duration,
// --marquee-delay, --marquee-loop-count) but no keyframes, so the scroll
// animation lives here with the component. Render the strip's items TWICE
// inside Marquee.Content (the second copy aria-hidden) — the keyframes
// translate by -50%, so the duplicate makes the loop seamless.
const marqueeScroll = stylex.keyframes({
  from: { transform: "translateX(0)" },
  to: { transform: "translateX(-50%)" },
});

const marqueeLocal = stylex.create({
  content: {
    animationName: marqueeScroll,
    "--marquee-duration": "20s",
    "--marquee-delay": "0s",
    "--marquee-loop-count": "infinite",
  },
  edgeStart: {
    backgroundImage:
      "linear-gradient(to right, var(--marquee-edge-color), transparent)",
    insetBlock: 0,
    insetInlineStart: 0,
    width: "var(--marquee-edge-size)",
  },
  edgeEnd: {
    backgroundImage:
      "linear-gradient(to left, var(--marquee-edge-color), transparent)",
    insetBlock: 0,
    insetInlineEnd: 0,
    width: "var(--marquee-edge-size)",
  },
});

// defineSlotRecipe validates the shape at compile time: default values must
// exist in the axis maps, and slot keys must be `styles` or a declared axis
const marqueeSlotRecipe = defineSlotRecipe({
  slots: {
    root: { styles: marqueeRoot },
    viewport: { styles: marqueeViewport },
    content: { styles: marqueeContent },
    edge: { styles: marqueeEdge },
  },
  defaultVariants: {},
});

/**
 * Marquee — recipe and component colocated in one file; each part composes
 * via `render`. Override the pace per instance through the custom
 * properties (`--marquee-duration`, `--marquee-delay`, `--marquee-loop-count`)
 * and the fade through `--marquee-edge-color` / `--marquee-edge-size`; the
 * recipe pauses the animation for prefers-reduced-motion.
 */
const { withProvider, withContext } = createSlotRecipeContext(marqueeSlotRecipe);

export const Marquee = {
  Root: withProvider("div", "root", "MarqueeRoot"),
  Viewport: withContext("div", "viewport", "MarqueeViewport"),
  Content: withContext(
    "div",
    () => [marqueeContent.base, marqueeLocal.content],
    "MarqueeContent",
  ),
  EdgeStart: withContext(
    "div",
    () => [marqueeEdge.base, marqueeLocal.edgeStart],
    "MarqueeEdgeStart",
  ),
  EdgeEnd: withContext(
    "div",
    () => [marqueeEdge.base, marqueeLocal.edgeEnd],
    "MarqueeEdgeEnd",
  ),
};
```
