# Marquee

Endless horizontal or vertical scroll of any content, with faded edges, reverse direction, and a pause on hover or focus.

- Category: Animations
- Status: stable
- Registry: https://markas.jenderalcorp.com/r/marquee.json
- CLI: `npx markasui@latest add marquee`

## When to use

Showing logos, testimonials, tags, or a live feed as decorative, continuously moving content.

- Pass the items of one loop only; the component duplicates them
- Give a vertical marquee a fixed height
- Do not put the only copy of important information in a marquee
- Blade needs Alpine.js

## Code

### Blade

Save at `resources/views/components/markas/marquee.blade.php`. Dependencies: alpinejs.

```blade
@props([
    'vertical' => false,
    'reverse' => false,
    'duration' => 20,
    'pauseOnHover' => true,
    'fade' => true,
])

@php
    $root = 'flex overflow-hidden';
    $copy = 'flex shrink-0 justify-around gap-4';
    $orientations = [
        'horizontal' => ['root' => 'flex-row', 'copy' => 'min-w-full flex-row pr-4'],
        'vertical' => ['root' => 'flex-col', 'copy' => 'min-h-full flex-col pb-4'],
    ];
    $fades = [
        'horizontal' => 'mask-x-from-85%',
        'vertical' => 'mask-y-from-85%',
    ];

    $orientation = $vertical ? 'vertical' : 'horizontal';
@endphp

<div
    x-data="{
        animations: [],
        observer: null,
        hover: false,
        focus: false,
        hidden: false,
        {{-- Geser setiap salinan sejauh lebarnya sendiri tanpa henti. --}}
        init() {
            if (window.matchMedia?.('(prefers-reduced-motion: reduce)').matches) return;
            const axis = @js($vertical ? 'Y' : 'X');
            this.animations = Array.from(this.$el.children).flatMap((child) => child.animate?.(
                [{ transform: `translate${axis}(0)` }, { transform: `translate${axis}(-100%)` }],
                { duration: @js((float) $duration) * 1000, iterations: Infinity, direction: @js($reverse ? 'reverse' : 'normal') },
            ) ?? []);
            if (typeof IntersectionObserver === 'undefined') return;
            this.observer = new IntersectionObserver((entries) => {
                this.hidden = ! entries.some((entry) => entry.isIntersecting);
                this.sync();
            });
            this.observer.observe(this.$el);
        },
        {{-- Berhenti saat kursor di atas, fokus di dalam, atau marquee di luar layar. --}}
        sync() {
            const paused = (@js((bool) $pauseOnHover) && this.hover) || this.focus || this.hidden;
            this.animations.forEach((animation) => (paused ? animation.pause() : animation.play()));
        },
        destroy() {
            this.observer?.disconnect();
            this.animations.forEach((animation) => animation.cancel());
        },
    }"
    @mouseenter="hover = true; sync()"
    @mouseleave="hover = false; sync()"
    @focusin="focus = true; sync()"
    @focusout="focus = false; sync()"
    {{ $attributes->class([$root, $orientations[$orientation]['root'], $fades[$orientation] => $fade]) }}
>
    <div class="{{ $copy }} {{ $orientations[$orientation]['copy'] }}">{{ $slot }}</div>
    <div aria-hidden="true" inert class="{{ $copy }} {{ $orientations[$orientation]['copy'] }}">{{ $slot }}</div>
</div>
```

```blade
<x-markas.marquee :duration="25">
    @foreach ($logos as $logo)
        <img src="{{ $logo['src'] }}" alt="{{ $logo['name'] }}" class="h-8" />
    @endforeach
</x-markas.marquee>

<x-markas.marquee vertical reverse class="h-64">...</x-markas.marquee>
```

### React

Save at `src/components/markas/Marquee.tsx`. No extra dependencies.

```tsx
"use client";

import { useEffect, useRef, type ComponentProps } from "react";

const root = "flex overflow-hidden";
const copy = "flex shrink-0 justify-around gap-4";
const orientations = {
  horizontal: { root: "flex-row", copy: "min-w-full flex-row pr-4" },
  vertical: { root: "flex-col", copy: "min-h-full flex-col pb-4" },
};
const fades = {
  horizontal: "mask-x-from-85%",
  vertical: "mask-y-from-85%",
};
const COPIES = [0, 1];
const MS_PER_SECOND = 1000;

const cx = (...c: (string | false | null | undefined)[]) =>
  c.filter(Boolean).join(" ");

const reducedMotion = () =>
  typeof matchMedia === "function" &&
  matchMedia("(prefers-reduced-motion: reduce)").matches;

/**
 * Geser setiap salinan sejauh lebarnya sendiri tanpa henti. Berhenti saat kursor di atas, fokus di dalam,
 * atau marquee di luar layar. Mengembalikan fungsi pelepas.
 */
function startMarquee(
  element: HTMLElement,
  options: {
    vertical: boolean;
    reverse: boolean;
    duration: number;
    pauseOnHover: boolean;
  },
) {
  const axis = options.vertical ? "Y" : "X";
  const animations = Array.from(element.children).flatMap(
    (child) =>
      child.animate?.(
        [
          { transform: `translate${axis}(0)` },
          { transform: `translate${axis}(-100%)` },
        ],
        {
          duration: options.duration * MS_PER_SECOND,
          iterations: Infinity,
          direction: options.reverse ? "reverse" : "normal",
        },
      ) ?? [],
  );
  const state = { hover: false, focus: false, hidden: false };
  const sync = () => {
    const paused =
      (options.pauseOnHover && state.hover) || state.focus || state.hidden;
    for (const animation of animations)
      if (paused) animation.pause();
      else animation.play();
  };
  const listeners: [string, () => void][] = [
    ["mouseenter", () => ((state.hover = true), sync())],
    ["mouseleave", () => ((state.hover = false), sync())],
    ["focusin", () => ((state.focus = true), sync())],
    ["focusout", () => ((state.focus = false), sync())],
  ];
  for (const [type, listener] of listeners)
    element.addEventListener(type, listener);
  const observer =
    typeof IntersectionObserver === "undefined"
      ? undefined
      : new IntersectionObserver((entries) => {
          state.hidden = !entries.some((entry) => entry.isIntersecting);
          sync();
        });
  observer?.observe(element);

  return () => {
    observer?.disconnect();
    for (const [type, listener] of listeners)
      element.removeEventListener(type, listener);
    for (const animation of animations) animation.cancel();
  };
}

export type MarqueeProps = ComponentProps<"div"> & {
  vertical?: boolean;
  reverse?: boolean;
  duration?: number;
  pauseOnHover?: boolean;
  fade?: boolean;
};

export function Marquee({
  vertical = false,
  reverse = false,
  duration = 20,
  pauseOnHover = true,
  fade = true,
  className,
  children,
  ...props
}: MarqueeProps) {
  const rootRef = useRef<HTMLDivElement>(null);
  const orientation = vertical ? "vertical" : "horizontal";

  useEffect(() => {
    const element = rootRef.current;
    if (!element || reducedMotion()) return;
    return startMarquee(element, { vertical, reverse, duration, pauseOnHover });
  }, [vertical, reverse, duration, pauseOnHover]);

  return (
    <div
      ref={rootRef}
      {...props}
      className={cx(
        root,
        orientations[orientation].root,
        fade && fades[orientation],
        className,
      )}
    >
      {COPIES.map((index) => (
        <div
          key={index}
          aria-hidden={index > 0 ? true : undefined}
          inert={index > 0}
          className={cx(copy, orientations[orientation].copy)}
        >
          {children}
        </div>
      ))}
    </div>
  );
}
```

```tsx
import { Marquee } from "@/components/markas/Marquee";

<Marquee duration={25}>
  {logos.map((logo) => (
    <img key={logo.name} src={logo.src} alt={logo.name} className="h-8" />
  ))}
</Marquee>

<Marquee vertical reverse className="h-64">...</Marquee>
```

### Vue

Save at `src/components/markas/Marquee.vue`. No extra dependencies.

```vue
<script setup lang="ts">
import { onBeforeUnmount, onMounted, useTemplateRef, watch } from "vue";

const props = withDefaults(
  defineProps<{
    vertical?: boolean;
    reverse?: boolean;
    duration?: number;
    pauseOnHover?: boolean;
    fade?: boolean;
  }>(),
  {
    vertical: false,
    reverse: false,
    duration: 20,
    pauseOnHover: true,
    fade: true,
  },
);

const root = "flex overflow-hidden";
const copy = "flex shrink-0 justify-around gap-4";
const orientations = {
  horizontal: { root: "flex-row", copy: "min-w-full flex-row pr-4" },
  vertical: { root: "flex-col", copy: "min-h-full flex-col pb-4" },
};
const fades = {
  horizontal: "mask-x-from-85%",
  vertical: "mask-y-from-85%",
};
const COPIES = [0, 1];
const MS_PER_SECOND = 1000;

const reducedMotion = () =>
  typeof matchMedia === "function" &&
  matchMedia("(prefers-reduced-motion: reduce)").matches;

/**
 * Geser setiap salinan sejauh lebarnya sendiri tanpa henti. Berhenti saat kursor di atas, fokus di dalam,
 * atau marquee di luar layar. Mengembalikan fungsi pelepas.
 */
function startMarquee(
  element: HTMLElement,
  options: {
    vertical: boolean;
    reverse: boolean;
    duration: number;
    pauseOnHover: boolean;
  },
) {
  const axis = options.vertical ? "Y" : "X";
  const animations = Array.from(element.children).flatMap(
    (child) =>
      child.animate?.(
        [
          { transform: `translate${axis}(0)` },
          { transform: `translate${axis}(-100%)` },
        ],
        {
          duration: options.duration * MS_PER_SECOND,
          iterations: Infinity,
          direction: options.reverse ? "reverse" : "normal",
        },
      ) ?? [],
  );
  const state = { hover: false, focus: false, hidden: false };
  const sync = () => {
    const paused =
      (options.pauseOnHover && state.hover) || state.focus || state.hidden;
    for (const animation of animations)
      if (paused) animation.pause();
      else animation.play();
  };
  const listeners: [string, () => void][] = [
    ["mouseenter", () => ((state.hover = true), sync())],
    ["mouseleave", () => ((state.hover = false), sync())],
    ["focusin", () => ((state.focus = true), sync())],
    ["focusout", () => ((state.focus = false), sync())],
  ];
  for (const [type, listener] of listeners)
    element.addEventListener(type, listener);
  const observer =
    typeof IntersectionObserver === "undefined"
      ? undefined
      : new IntersectionObserver((entries) => {
          state.hidden = !entries.some((entry) => entry.isIntersecting);
          sync();
        });
  observer?.observe(element);

  return () => {
    observer?.disconnect();
    for (const [type, listener] of listeners)
      element.removeEventListener(type, listener);
    for (const animation of animations) animation.cancel();
  };
}

const rootEl = useTemplateRef<HTMLDivElement>("rootRef");
let stop = () => {};

function start() {
  stop();
  stop = () => {};
  const element = rootEl.value;
  if (!element || reducedMotion()) return;
  stop = startMarquee(element, {
    vertical: props.vertical,
    reverse: props.reverse,
    duration: props.duration,
    pauseOnHover: props.pauseOnHover,
  });
}

const orientation = () => (props.vertical ? "vertical" : "horizontal");

onMounted(start);
watch(
  () => [props.vertical, props.reverse, props.duration, props.pauseOnHover],
  start,
  { flush: "post" },
);
onBeforeUnmount(() => stop());
</script>

<template>
  <div
    ref="rootRef"
    :class="[
      root,
      orientations[orientation()].root,
      props.fade && fades[orientation()],
    ]"
  >
    <div
      v-for="index in COPIES"
      :key="index"
      :aria-hidden="index > 0 ? 'true' : undefined"
      :inert="index > 0 ? true : undefined"
      :class="[copy, orientations[orientation()].copy]"
    >
      <slot />
    </div>
  </div>
</template>
```

```vue
<template>
  <Marquee :duration="25">
    <img
      v-for="logo in logos"
      :key="logo.name"
      :src="logo.src"
      :alt="logo.name"
      class="h-8"
    />
  </Marquee>

  <Marquee vertical reverse class="h-64">...</Marquee>
</template>
```

### Svelte

Save at `src/lib/components/markas/Marquee.svelte`. No extra dependencies.

```svelte
<script lang="ts">
  import type { Snippet } from "svelte";
  import type { HTMLAttributes } from "svelte/elements";

  const root = "flex overflow-hidden";
  const copy = "flex shrink-0 justify-around gap-4";
  const orientations = {
    horizontal: { root: "flex-row", copy: "min-w-full flex-row pr-4" },
    vertical: { root: "flex-col", copy: "min-h-full flex-col pb-4" },
  };
  const fades = {
    horizontal: "mask-x-from-85%",
    vertical: "mask-y-from-85%",
  };
  const COPIES = [0, 1];
  const MS_PER_SECOND = 1000;

  const reducedMotion = () =>
    typeof matchMedia === "function" &&
    matchMedia("(prefers-reduced-motion: reduce)").matches;

  /**
   * Moves every copy by its own size, forever. Pauses while hovered, while focus is inside,
   * or while the marquee is off screen. Returns a cleanup function.
   */
  function startMarquee(
    element: HTMLElement,
    options: {
      vertical: boolean;
      reverse: boolean;
      duration: number;
      pauseOnHover: boolean;
    },
  ) {
    const axis = options.vertical ? "Y" : "X";
    const animations = Array.from(element.children).flatMap(
      (child) =>
        child.animate?.(
          [
            { transform: `translate${axis}(0)` },
            { transform: `translate${axis}(-100%)` },
          ],
          {
            duration: options.duration * MS_PER_SECOND,
            iterations: Infinity,
            direction: options.reverse ? "reverse" : "normal",
          },
        ) ?? [],
    );
    const state = { hover: false, focus: false, hidden: false };
    const sync = () => {
      const paused =
        (options.pauseOnHover && state.hover) || state.focus || state.hidden;
      for (const animation of animations)
        if (paused) animation.pause();
        else animation.play();
    };
    const listeners: [string, () => void][] = [
      ["mouseenter", () => ((state.hover = true), sync())],
      ["mouseleave", () => ((state.hover = false), sync())],
      ["focusin", () => ((state.focus = true), sync())],
      ["focusout", () => ((state.focus = false), sync())],
    ];
    for (const [type, listener] of listeners)
      element.addEventListener(type, listener);
    const observer =
      typeof IntersectionObserver === "undefined"
        ? undefined
        : new IntersectionObserver((entries) => {
            state.hidden = !entries.some((entry) => entry.isIntersecting);
            sync();
          });
    observer?.observe(element);

    return () => {
      observer?.disconnect();
      for (const [type, listener] of listeners)
        element.removeEventListener(type, listener);
      for (const animation of animations) animation.cancel();
    };
  }

  type Props = HTMLAttributes<HTMLDivElement> & {
    vertical?: boolean;
    reverse?: boolean;
    /** Seconds for one full loop. */
    duration?: number;
    pauseOnHover?: boolean;
    fade?: boolean;
    children?: Snippet;
  };

  let {
    vertical = false,
    reverse = false,
    duration = 20,
    pauseOnHover = true,
    fade = true,
    class: className,
    children,
    ...rest
  }: Props = $props();

  let element = $state<HTMLDivElement>();
  const orientation = $derived(vertical ? "vertical" : "horizontal");

  $effect(() => {
    const options = { vertical, reverse, duration, pauseOnHover };
    if (!element || reducedMotion()) return;
    return startMarquee(element, options);
  });
</script>

<div
  bind:this={element}
  {...rest}
  class={[
    root,
    orientations[orientation].root,
    fade && fades[orientation],
    className,
  ]}
>
  {#each COPIES as index (index)}
    <div
      aria-hidden={index > 0 ? "true" : undefined}
      inert={index > 0}
      class={[copy, orientations[orientation].copy]}
    >
      {@render children?.()}
    </div>
  {/each}
</div>
```

```svelte
<script lang="ts">
  import Marquee from "$lib/components/markas/Marquee.svelte";
</script>

<Marquee duration={25}>
  {#each logos as logo (logo.name)}
    <img src={logo.src} alt={logo.name} class="h-8" />
  {/each}
</Marquee>

<Marquee vertical reverse class="h-64">...</Marquee>
```

### Astro

Save at `src/components/markas/Marquee.astro`. No extra dependencies.

```astro
---
import type { HTMLAttributes } from "astro/types";

const root = "flex overflow-hidden";
const copy = "flex shrink-0 justify-around gap-4";
const orientations = {
  horizontal: { root: "flex-row", copy: "min-w-full flex-row pr-4" },
  vertical: { root: "flex-col", copy: "min-h-full flex-col pb-4" },
};
const fades = {
  horizontal: "mask-x-from-85%",
  vertical: "mask-y-from-85%",
};

type Props = HTMLAttributes<"div"> & {
  vertical?: boolean;
  reverse?: boolean;
  /** Seconds for one full loop. */
  duration?: number;
  pauseOnHover?: boolean;
  fade?: boolean;
};

const {
  vertical = false,
  reverse = false,
  duration = 20,
  pauseOnHover = true,
  fade = true,
  class: className,
  ...rest
} = Astro.props;
const orientation = vertical ? "vertical" : "horizontal";
// A slot renders once, so the same HTML fills the visible copy and the hidden one.
const content = await Astro.slots.render("default");
---

<markas-marquee
  class="contents"
  data-vertical={vertical ? "" : undefined}
  data-reverse={reverse ? "" : undefined}
  data-duration={duration}
  data-pause-on-hover={pauseOnHover ? "" : undefined}
>
  <div
    {...rest}
    class:list={[
      root,
      orientations[orientation].root,
      fade && fades[orientation],
      className,
    ]}
  >
    <div class:list={[copy, orientations[orientation].copy]}>
      <Fragment set:html={content} />
    </div>
    <div aria-hidden="true" inert class:list={[copy, orientations[orientation].copy]}>
      <Fragment set:html={content} />
    </div>
  </div>
</markas-marquee>

<script>
  const MS_PER_SECOND = 1000;

  // One element per marquee: setup runs for markup added later and after view transitions.
  class MarkasMarquee extends HTMLElement {
    private cleanup = () => {};

    connectedCallback() {
      const element = this.firstElementChild as HTMLElement | null;
      if (!element || matchMedia("(prefers-reduced-motion: reduce)").matches)
        return;
      const axis = this.hasAttribute("data-vertical") ? "Y" : "X";
      const pauseOnHover = this.hasAttribute("data-pause-on-hover");
      // Move every copy by its own size, forever.
      const animations = Array.from(element.children).flatMap(
        (child) =>
          child.animate?.(
            [
              { transform: `translate${axis}(0)` },
              { transform: `translate${axis}(-100%)` },
            ],
            {
              duration: Number(this.dataset.duration) * MS_PER_SECOND,
              iterations: Infinity,
              direction: this.hasAttribute("data-reverse") ? "reverse" : "normal",
            },
          ) ?? [],
      );
      // Pause while hovered, while focus is inside, or while off screen.
      const state = { hover: false, focus: false, hidden: false };
      const sync = () => {
        const paused = (pauseOnHover && state.hover) || state.focus || state.hidden;
        for (const animation of animations)
          if (paused) animation.pause();
          else animation.play();
      };
      const listeners: [string, () => void][] = [
        ["mouseenter", () => ((state.hover = true), sync())],
        ["mouseleave", () => ((state.hover = false), sync())],
        ["focusin", () => ((state.focus = true), sync())],
        ["focusout", () => ((state.focus = false), sync())],
      ];
      for (const [type, listener] of listeners)
        element.addEventListener(type, listener);
      const observer = new IntersectionObserver((entries) => {
        state.hidden = !entries.some((entry) => entry.isIntersecting);
        sync();
      });
      observer.observe(element);
      this.cleanup = () => {
        observer.disconnect();
        for (const [type, listener] of listeners)
          element.removeEventListener(type, listener);
        for (const animation of animations) animation.cancel();
      };
    }

    disconnectedCallback() {
      this.cleanup();
    }
  }

  if (!customElements.get("markas-marquee"))
    customElements.define("markas-marquee", MarkasMarquee);
</script>
```

```astro
---
import Marquee from "@/components/markas/Marquee.astro";
---

<Marquee duration={25}>
  {logos.map((logo) => <img src={logo.src} alt={logo.name} class="h-8" />)}
</Marquee>
```

### Angular

Save at `src/app/markas/marquee.component.ts`. No extra dependencies.

```ts
import {
  afterNextRender,
  afterRenderEffect,
  booleanAttribute,
  ChangeDetectionStrategy,
  Component,
  computed,
  ElementRef,
  inject,
  input,
  numberAttribute,
  viewChild,
} from "@angular/core";

const root = "flex overflow-hidden";
const copy = "flex shrink-0 justify-around gap-4";
const orientations = {
  horizontal: { root: "flex-row", copy: "min-w-full flex-row pr-4" },
  vertical: { root: "flex-col", copy: "min-h-full flex-col pb-4" },
};
const fades = {
  horizontal: "mask-x-from-85%",
  vertical: "mask-y-from-85%",
};
const MS_PER_SECOND = 1000;

const reducedMotion = () =>
  typeof matchMedia === "function" &&
  matchMedia("(prefers-reduced-motion: reduce)").matches;

type MarqueeOptions = {
  vertical: boolean;
  reverse: boolean;
  duration: number;
  pauseOnHover: boolean;
};

/**
 * Moves every copy by its own size, forever. Pauses while hovered, while focus is inside,
 * or while the marquee is off screen. Returns a cleanup function.
 */
function startMarquee(element: HTMLElement, options: MarqueeOptions) {
  const axis = options.vertical ? "Y" : "X";
  const animations = Array.from(element.children).flatMap(
    (child) =>
      child.animate?.(
        [
          { transform: `translate${axis}(0)` },
          { transform: `translate${axis}(-100%)` },
        ],
        {
          duration: options.duration * MS_PER_SECOND,
          iterations: Infinity,
          direction: options.reverse ? "reverse" : "normal",
        },
      ) ?? [],
  );
  const state = { hover: false, focus: false, hidden: false };
  const sync = () => {
    const paused =
      (options.pauseOnHover && state.hover) || state.focus || state.hidden;
    for (const animation of animations)
      if (paused) animation.pause();
      else animation.play();
  };
  const listeners: [string, () => void][] = [
    ["mouseenter", () => ((state.hover = true), sync())],
    ["mouseleave", () => ((state.hover = false), sync())],
    ["focusin", () => ((state.focus = true), sync())],
    ["focusout", () => ((state.focus = false), sync())],
  ];
  for (const [type, listener] of listeners)
    element.addEventListener(type, listener);
  const observer =
    typeof IntersectionObserver === "undefined"
      ? undefined
      : new IntersectionObserver((entries) => {
          state.hidden = !entries.some((entry) => entry.isIntersecting);
          sync();
        });
  observer?.observe(element);

  return () => {
    observer?.disconnect();
    for (const [type, listener] of listeners)
      element.removeEventListener(type, listener);
    for (const animation of animations) animation.cancel();
  };
}

/**
 * Attribute selector on the root div. ng-content projects once, so the hidden copy is a clone
 * of the visible one made after the first render.
 */
@Component({
  selector: "div[markas-marquee]",
  changeDetection: ChangeDetectionStrategy.OnPush,
  host: { "[class]": "classes()" },
  template: `
    <div #firstEl [class]="copyClasses()"><ng-content /></div>
    <div #cloneEl aria-hidden="true" inert [class]="copyClasses()"></div>
  `,
})
export class Marquee {
  readonly vertical = input(false, { transform: booleanAttribute });
  readonly reverse = input(false, { transform: booleanAttribute });
  /** Seconds for one full loop. */
  readonly duration = input(20, { transform: numberAttribute });
  readonly pauseOnHover = input(true, { transform: booleanAttribute });
  readonly fade = input(true, { transform: booleanAttribute });

  private readonly orientation = computed(() =>
    this.vertical() ? "vertical" : "horizontal",
  );
  protected readonly classes = computed(() =>
    [
      root,
      orientations[this.orientation()].root,
      this.fade() && fades[this.orientation()],
    ]
      .filter(Boolean)
      .join(" "),
  );
  protected readonly copyClasses = computed(
    () => `${copy} ${orientations[this.orientation()].copy}`,
  );
  private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);
  private readonly first =
    viewChild.required<ElementRef<HTMLElement>>("firstEl");
  private readonly clone =
    viewChild.required<ElementRef<HTMLElement>>("cloneEl");

  constructor() {
    afterNextRender(() =>
      this.clone().nativeElement.replaceChildren(
        ...[...this.first().nativeElement.childNodes].map((node) =>
          node.cloneNode(true),
        ),
      ),
    );
    afterRenderEffect((onCleanup) => {
      const options = {
        vertical: this.vertical(),
        reverse: this.reverse(),
        duration: this.duration(),
        pauseOnHover: this.pauseOnHover(),
      };
      if (reducedMotion()) return;
      onCleanup(startMarquee(this.host.nativeElement, options));
    });
  }
}
```

```ts
import { Component } from "@angular/core";
import { Marquee } from "./markas/marquee.component";

@Component({
  selector: "app-logos",
  imports: [Marquee],
  template: `
    <div markas-marquee duration="25">
      @for (logo of logos; track logo.name) {
        <img [src]="logo.src" [alt]="logo.name" class="h-8" />
      }
    </div>
  `,
})
export class Logos {
  logos = [{ name: "Laravel", src: "/laravel.svg" }];
}
```

## Props

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `vertical` | `boolean` | false | Scroll from bottom to top. Give the marquee a height, such as h-64. |
| `reverse` | `boolean` | false | Scroll in the opposite direction. |
| `duration` | `number` | 20 | Seconds for one full loop. Higher is slower. |
| `pauseOnHover` | `boolean` | true | Pause while the pointer is over the marquee. Focus inside always pauses it. |
| `fade` | `boolean` | true | Fade the content out at both edges with a CSS mask. |
| `children / slot` | `ReactNode / slot` | - | Items in one loop, laid out in a row (or column) with a 16px gap. |

## Accessibility

- The content is rendered twice for a seamless loop; the second copy is aria-hidden and inert, so screen readers and the Tab key reach each item once.
- The animation pauses on hover, while focus is inside, and when the marquee is off screen.
- With reduced motion, nothing moves and the first items stay visible.
- Moving content longer than 5 seconds needs a way to stop it (WCAG 2.2.2): keep essential information out of the marquee or offer it elsewhere.

## Notes

- Pass the items of one loop. The component renders them twice; the copy is `aria-hidden` and `inert`.
- Each copy is at least as wide as the marquee, so short lists still loop without a gap.
- Motion uses the Web Animations API and pauses on hover, on focus inside, and off screen. The Blade version needs Alpine.js.
- In Angular, `ng-content` projects once, so the hidden copy is a clone of the items made after the first render. Changes to the items after that are not copied.
- With reduced motion, nothing moves. Do not put information users need only inside a marquee.
