Animation

Marquee

Endless rAF-driven horizontal carousel. Pass items as image sources or Angular templates; the track auto-duplicates to cover the container. Optional edge fades, pause/scale-on-hover, custom hover speed.

Angular adaptation of an effect by David Haz / reactbits.dev.

Import

import { WrMarquee } from 'ngwr/marquee';

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

Types

Entry shapes accepted by [items].

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;
}
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—
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—

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

Custom properties ngwr/marquee publishes. Each default below is declared on the component's own selector, so a :root override is shadowed by it — set them on that selector, on a wrapper you scope yourself, or inline on the element. Unlike the BEM class names, these are the supported way to restyle the component.

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