# marquee

An endless ticker of a row of text, logos or images that speeds up and leans as the page scrolls.

The content of the element runs sideways in a seamless loop, with copies following each other at an even gap, and fades out softly at both ends. Scrolling the page pushes it faster and tips it forward in the direction it runs; it can also turn around when the page scrolls up. It slows to a stop under the mouse or keyboard focus and picks up again after. The content stays in the page once, so screen readers read it once while the copies you see are drawn by the GPU.

Module `text`, category Text. Import `@dioramajs/text/marquee`. [Source](https://github.com/MasterKurosava/diorama/blob/main/packages/text/src/marquee.ts)

A row of six partner logos that runs left in an endless loop, faster while the page scrolls.

```html title="index.html"
<section class="mq-trust">
  <p class="mq-label">Trusted by finance teams at</p>
  <ul class="mq-logos" data-dio="marquee">
    <li><svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="12" cy="12" r="10" /></svg>Northwind</li>
    <li><svg viewBox="0 0 24 24" aria-hidden="true"><rect x="3" y="3" width="18" height="18" rx="5" /></svg>Halcyon</li>
    <li><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 2 22 21H2Z" /></svg>Vertex</li>
    <li><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M3 12h18M12 3v18" stroke="currentColor" stroke-width="5" /></svg>Plusform</li>
    <li><svg viewBox="0 0 24 24" aria-hidden="true"><circle cx="8" cy="12" r="6" /><circle cx="16" cy="12" r="6" opacity="0.55" /></svg>Overlap</li>
    <li><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M2 20 9 4l4 9 3-5 6 12Z" /></svg>Ridgeline</li>
  </ul>
</section>
```

## Usage

Put it on: a row of text, logos, inline SVGs or images laid out on one line, such as a flex row. Not img, video, canvas, svg or form fields.

`start()` registers `marquee`, so the attribute alone puts it on an element.

```html
<ul class="logos" data-dio="marquee"><li><img src="/logos/arc.svg" alt="Arc"></li><li><img src="/logos/vale.svg" alt="Vale"></li><li><img src="/logos/nord.svg" alt="Nord"></li></ul>
```

In page transitions: Fades with the page.

## Params

| Name | Attribute | Type | Default | Description |
| --- | --- | --- | --- | --- |
| `direction` (rebuilds) | `data-dio-direction` | `'left' \| 'right'` | `'left'` | left runs the content to the left; right runs it to the right. |
| `speed` | `data-dio-speed` | `number` 0 to 400 px | `60` | Pace without scrolling; 0 moves it only while the page scrolls. |
| `gap` | `data-dio-gap` | `number` 0 to 400 px | `0` | Extra space between copies, on top of the row gap (1em for plain text). |
| `boost` | `data-dio-boost` | `number` 0 to 2 | `0.3` | Extra travel per pixel of page scroll; 0 ignores the scroll. |
| `skew` | `data-dio-skew` | `number` 0 to 30° | `6` | Lean into the motion during a fast scroll; 0 keeps it upright. |
| `reverse` | `data-dio-reverse` | `boolean` | `false` | Scrolling up turns the ticker around until the page scrolls down. |
| `pause` | `data-dio-pause` | `boolean` | `true` | Slows to a stop under the mouse or keyboard focus. |
| `fade` | `data-dio-fade` | `number` 0 to 0.5 | `0.08` | Soft edge at each side, as a share of the width; 0 for hard edges. |

Changing a param marked rebuilds re-runs the effect setup.

### Variants

- `direction`: `left`, `right`
  - `left` runs the content to the left.
  - `right` runs it to the right.

## Inputs and frames

Reads [`delta`](/docs/api/inputs#input-delta), [`reducedMotion`](/docs/api/inputs#input-reducedMotion), [`size`](/docs/api/inputs#size), [`velocity`](/docs/api/inputs#velocity). Draws at a steady rate while it is on screen and stops when it leaves. Up to 60 a second while it moves and is on screen; none off screen, paused or at speed 0 without scrolling. See [how a frame is decided](/docs/concepts/frames).

## Reduced motion and touch

With reduced motion it shows a still frame: motion inputs are zero and time stands still. Static: the row stands still with its copies, and scrolling does not move it.

Runs on every device. The same, without the pause: a finger on it scrolls the page and pushes the ticker.

```ts
import { start } from '@dioramajs/diorama'

start({ effects: { marquee: { reducedMotion: 'off' } } })
```

## Cost and quality

Loads 8.8 KB the first time a page uses it. GPU: One quad over the element, one texture read per pixel. Memory: A canvas of one copy of the content at the screen density, without mip levels: about 1.4 MB for a 3000 x 60 row at 2x.

- low: The content is drawn at 1 device pixel per CSS pixel.

See [the quality plugin](/docs/effects/quality).

## Recipes

### A logo row under the hero

Lay the logos out as one flex row with a `gap`, give each item `flex: none` so it keeps its width, and clip the row with `overflow: hidden`. The effect repeats the row with the same gap between copies, so you write each logo once. Inline SVGs keep their colors from your CSS, and `opacity` or a `filter: grayscale(1)` on a logo carries over too.

```html
<ul class="logos" data-dio="marquee">
  <li><img src="/logos/northwind.svg" /></li>
  <li><img src="/logos/halcyon.svg" /></li>
  <li><img src="/logos/vertex.svg" /></li>
</ul>
```

### A big ticker that turns with the scroll

Agency and event sites often run one huge line across the page. `data-dio-reverse="true"` turns it around when the visitor scrolls up, and a larger `skew` makes it lean harder while the page moves. Scroll past this example to see it.

A full-width band of large uppercase type that runs left and turns around when the page scrolls up.

```html title="index.html"
<div class="mq-band">
  <p class="mq-ticker" data-dio="marquee" data-dio-speed="90" data-dio-reverse="true" data-dio-skew="10" data-dio-fade="0">Now booking spring 2027 · Lisbon · Kyoto · Mexico City ·</p>
</div>
```

### Moving only while the page scrolls

With `data-dio-speed="0"` the row stands still until the visitor scrolls, and `boost` sets how far it travels per pixel of scroll. It reads as a part of the scroll rather than an animation of its own, and it draws no frames while the page rests.

```html
<p
  class="band"
  data-dio="marquee"
  data-dio-speed="0"
  data-dio-boost="0.6"
  data-dio-direction="right"
>Design · Build · Ship · Repeat ·</p>
```

## Notes

The content stays in the page once, as you wrote it: screen readers and search engines read it once, and a CSS filter hides it while the copies run. Links inside stay where the page lays them out rather than where the copies move, so for a row of links keep `pause` on: the row slows to a stop under the mouse or keyboard focus, which also gives visitors a way to stop moving content.

The effect draws backgrounds, borders and corner radii of the items in the row, images with their `object-fit`, inline SVGs and text. It does not draw shadows, gradients or background images of the items, and the element’s own background stays put as a plain color under the moving content. An image from another origin needs CORS, or the row stays as it is with a warning in development.

The gap between copies is the row’s own `column-gap` for a flex or grid row and 1em for plain text, plus `gap`. Under reduced motion the row stands still, filled with copies, and scrolling does not move it. Off screen it draws no frames, and on screen it draws at most 60 a second.

`direction` rebuilds the effect when it changes; the other params change live.

## Related

- [assemble](/docs/effects/assemble.md): Thousands of lit particles fly out of the depth around the page and gather into a heading.
- [blinds](/docs/effects/blinds.md): A heading printed across real 3D slats that turn over in a wave, lit and casting shadows, to show it.
- [counter](/docs/effects/counter.md): Stats count up to their value on real 3D mechanics: odometer drums, slot machine reels or flip cards.
- [dust](/docs/effects/dust.md): A heading crumbles into fine sand that lifts off the page and drifts away in depth as it scrolls out, or on a click.
- [emboss](/docs/effects/emboss.md): Letters pressed into or raised out of paper, leather, brushed metal, stone or plaster, lit by a light that follows the pointer.
- [extrude](/docs/effects/extrude.md): A headline becomes a solid 3D block: beveled letters with lit side walls, seen in perspective, that turn toward the pointer.
- [fire](/docs/effects/fire.md): The letters burn: flames rise from their tops, sparks drift up in depth and the firelight flickers on the page.
- [hologram](/docs/effects/hologram.md): A heading becomes a 3D hologram: projected from a glowing emitter, built of slices in depth, crossed by scan lines.
- [Reduced motion](/docs/guides/reduced-motion.md)
- [Performance and quality](/docs/guides/performance.md)
