AnimationUpdated in v15

Marquee

An endless scrolling row of logos, images or templates.

Installation

Import the class, and @use the entry point in your global styles: without it the component renders unstyled.

import { Component } from '@angular/core';
import { WrMarquee } from 'ngwr/bits/marquee';

@Component({ imports: [WrMarquee] })
export class MyComponent {}
Angular adaptation of an effect by David Haz / reactbits.dev.

Playground

<wr-marquee
  [items]="items"
  [speed]="120"
  [gap]="48"
  [itemHeight]="36"
  direction="left"
  [pauseOnHover]="false"
  [fadeOut]="true"
/>

Customize

Speed (px/s)
120
Gap (px)
48 px
Item Height (px)
36 px
Direction
Pause on Hover
Fade Out

Reduced motion

With prefers-reduced-motion, the strip stops and scrolls instead: one copy of the items, no edge fades, and a tab stop on the strip when no item has one. Since v15.

Types

What items accepts.

type WrMarqueeItem = WrMarqueeImage | WrMarqueeNode;

interface WrMarqueeImage {
  src: string;
  alt?: string;
  href?: string;
  title?: string;
  width?: number;
  height?: number;
  srcSet?: string;
  sizes?: string;
}

interface WrMarqueeNode {
  node: TemplateRef<unknown>;
  href?: string;
  ariaLabel?: string;
  title?: string;
}
NameDescriptionTypeDefault
WrMarqueeItemUnion of the two entry kinds below.WrMarqueeImage | WrMarqueeNode—
WrMarqueeImageImage-driven entry.interface—
srcrequiredImage URL.string—
altAlt text.string—
hrefWraps the image in a link.string—
titleNative tooltip on the image.string—
width / heightIntrinsic size hints.number—
srcSet / sizesResponsive image attributes.string—
WrMarqueeNodeTemplate-driven entry.interface—
noderequiredTemplate rendered as the item.TemplateRef<unknown>—
hrefWraps the template in a link.string—
ariaLabelAccessible label for the link.string—
titleNative tooltip on the rendered template.string—

API

NameDescriptionTypeDefault
itemsrequiredItems to display. Each entry is either an image source or a TemplateRef node.readonly WrMarqueeItem[]—
speedScroll speed in pixels per second. Negative reverses direction.number120
directionTrack direction.'left' | 'right''left'
itemHeightItem height in pixels.number28
gapGap between items in pixels.number32
pauseOnHoverPause the loop on hover.booleanfalse
hoverSpeedCustom speed (px/s) when hovered. Overrides pauseOnHover.number | undefinedundefined
fadeOutApply edge fade-out gradients.booleanfalse
fadeOutColorCSS colour for the fade-out gradient. Defaults to the page background.string''
scaleOnHoverScale individual items up on hover.booleanfalse
ariaLabelAccessible name for the region. Falls back to marquee.label, then 'Marquee'.string | nullnull

CSS variables

Set these on the component's selector or a wrapper, not on :root: the defaults are declared on ngwr/bits/marquee's own element.

VariableDefaultDeclared on
--wr-marquee-fade-color-autovar(--wr-color-surface, #ffffff).wr-marquee
--wr-marquee-gap32px.wr-marquee
--wr-marquee-height28px.wr-marquee

See also