marquee
An endless ticker of a row of text, logos or images that speeds up and leans as the page scrolls.
Trusted by finance teams at
- Northwind
- Halcyon
- Vertex
- Plusform
- Overlap
- Ridgeline
Live preview needs WebGPU or WebGL 2. A row of six partner logos that runs left in an endless loop, faster while the page scrolls.
This example failed to draw.
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. The tabs below are the example above, with the values you set.
To change its code, copy the source into your effects folder; the copy replaces the built-in.
npx @dioramajs/diorama add marquee<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>import { start } from '@dioramajs/diorama'
const app = start()app.attach('.mq-logos', 'marquee', { direction: 'left', speed: 60, gap: 0, boost: 0.3, skew: 6, reverse: false, pause: true, fade: 0.08,})import { start } from '@dioramajs/diorama'import marquee from '@dioramajs/text/marquee'
const app = start()app.attach('.mq-logos', marquee({ direction: 'left', speed: 60, gap: 0, boost: 0.3, skew: 6, reverse: false, pause: true, fade: 0.08,}))Page transitions
Fades with the page. How a flight flies.
Params
Every param is also an attribute, and both app.attach() and the handle take it by name.
| Param | Type | Default | Description |
|---|---|---|---|
directionrebuildsdata-dio-direction | 'left' | 'right' | 'left' |
|
speeddata-dio-speed | number0 to 400 px | 60 | Pace without scrolling; 0 moves it only while the page scrolls. |
gapdata-dio-gap | number0 to 400 px | 0 | Extra space between copies, on top of the row gap (1em for plain text). |
boostdata-dio-boost | number0 to 2 | 0.3 | Extra travel per pixel of page scroll; 0 ignores the scroll. |
skewdata-dio-skew | number0 to 30° | 6 | Lean into the motion during a fast scroll; 0 keeps it upright. |
reversedata-dio-reverse | boolean | false | Scrolling up turns the ticker around until the page scrolls down. |
pausedata-dio-pause | boolean | true | Slows to a stop under the mouse or keyboard focus. |
fadedata-dio-fade | number0 to 0.5 | 0.08 | Soft edge at each side, as a share of the width; 0 for hard edges. |
Params marked rebuilds re-run the effect's setup when they change, so set them before the element shows.
Inputs and frames
It reads delta, reducedMotion, size and 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. How a frame is decided.
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.
To change what reduced motion does, patch it in start().
import { start } from '@dioramajs/diorama'
start({ effects: { marquee: { reducedMotion: 'off' } } })Cost and quality
- Download
- 8.8 KB min+gzip 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.
- Frames
- Draws while on screen
It runs from the low tier up. Each tier changes this: The quality plugin picks the tier for each device.
| Tier | What changes |
|---|---|
low | The content is drawn at 1 device pixel per CSS pixel. |
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.
<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.
Now booking spring 2027 · Lisbon · Kyoto · Mexico City ·
Live preview needs WebGPU or WebGL 2. A full-width band of large uppercase type that runs left and turns around when the page scrolls up.
This example failed to draw.
<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.
<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.