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 (images or template nodes).WrMarqueeItem[]— (required)
speedScroll speed in px/s. Negative reverses direction.number120
directionTrack direction.'left' | 'right''left'
itemHeightItem height in px.number28
gapGap between items in px.number32
pauseOnHoverPause the loop on hover.booleanfalse
hoverSpeedCustom speed when hovered. Overrides pauseOnHover.number
fadeOutApply edge fade-out gradients.booleanfalse
fadeOutColorFade-out gradient colour. Defaults to the lib surface colour (--wr-color-white).string
scaleOnHoverScale individual items up on hover.booleanfalse
ariaLabelAccessible label for the carousel region.string'Marquee'