---
title: Marquee for Astro
description: "Astro moving content rows with direction, duration, and spacing controls."
seo:
    title: Marquee for Astro | Shadcn & Tailwind CSS
related:
    - /components/carousel
    - Logos blocks: /blocks/logos
sidebar:
    label: "Marquee"
---

```astro
---
import { Marquee } from "@/components/ui/marquee"

const items = ["React", "Vue", "Angular", "Svelte", "Astro", "Next.js"]
---

<Marquee class="mask-x-from-95%">
  {items.map((item) => (
    <span class="text-muted-foreground text-sm">{item}</span>
  ))}
</Marquee>
```

## Installation

### Command

```sh
bunx --bun shadcn@latest add @gnostic/marquee
```

### Manual

Complete the [Installation guide](/docs/installation) first. Then copy the component files below.

No extra packages are required.

#### src/components/ui/marquee/index.ts

```ts
export { default as Marquee } from "./marquee.astro"
```

#### src/components/ui/marquee/marquee.astro

```astro
---
import type { HTMLAttributes } from "astro/types"
import { cva, type VariantProps } from "class-variance-authority"

import { cn } from "cn"

const trackVariants = cva(
  "flex min-w-max shrink-0 [animation:marquee_var(--marquee-duration)_linear_infinite] items-center gap-(--marquee-gap) before:block before:size-0 before:shrink-0 before:content-['']",
  {
    variants: {
      direction: {
        left: "",
        right: "[animation-direction:reverse]",
      },
      pauseOnHover: {
        true: "group-hover/marquee:[animation-play-state:paused]",
        false: "",
      },
    },
    defaultVariants: {
      direction: "left",
      pauseOnHover: false,
    },
  },
)

type Props = HTMLAttributes<"div"> &
  VariantProps<typeof trackVariants> & {
    duration?: string
    gap?: string
    infinite?: boolean
  }

const {
  class: className,
  direction,
  pauseOnHover,
  duration = "40s",
  gap = "1.5rem",
  infinite = true,
  style,
  ...props
} = Astro.props

const resolvedStyle = [
  `--marquee-duration:${duration}`,
  `--marquee-gap:${gap}`,
  typeof style === "string" ? style : undefined,
]
  .filter(Boolean)
  .join(";")
---

<div
  class={cn(
    "group/marquee flex overflow-hidden select-none [--marquee-duration:40s] [--marquee-gap:1.5rem]",
    className,
  )}
  style={resolvedStyle}
  {...props}
>
  <div class={trackVariants({ direction, pauseOnHover })}>
    <slot />
  </div>
  {infinite && (
    <div aria-hidden="true" class={trackVariants({ direction, pauseOnHover })}>
      <slot />
    </div>
  )}
</div>

<style>
  @keyframes marquee {
    from {
      transform: translateX(0);
    }

    to {
      transform: translateX(-100%);
    }
  }
</style>
```

Component classes use the preset configured during project setup. Select the same preset in the docs before copying Manual source. To change installed component classes, edit or reinstall their source. See [Theming](/docs/theming) for details.


## Usage

```ts
import { Marquee } from "@/components/ui/marquee"
```

```astro
<Marquee>
  <span>Design systems</span>
  <span>Astro</span>
  <span>Content sites</span>
</Marquee>
```

The marquee duplicates its slot by default for a seamless loop.

```astro
<Marquee>
  <span>Design systems</span>
  <span>Astro</span>
  <span>Content sites</span>
</Marquee>
```

## Examples

### Seamless Loop

```astro
---
import { Marquee } from "@/components/ui/marquee"

const items = ["React", "Vue", "Angular", "Svelte", "Astro", "Next.js"]
---

<Marquee class="mask-x-from-95%">
  {items.map((item) => (
    <span class="text-muted-foreground text-sm">{item}</span>
  ))}
</Marquee>
```

### Direction

Control the scroll direction with the `direction` prop.

```astro
---
import { Marquee } from "@/components/ui/marquee"

const items = ["TypeScript", "JavaScript", "Python", "Go", "Rust"]
---

<div class="flex flex-col gap-8">
  <Marquee class="mask-x-from-95%">
    {items.map((item) => (
      <span class="text-muted-foreground text-sm">{item}</span>
    ))}
  </Marquee>

  <Marquee class="mask-x-from-95%" direction="right">
    {items.map((item) => (
      <span class="text-muted-foreground text-sm">{item}</span>
    ))}
  </Marquee>
</div>
```

### Pause on Hover

Enable pause on hover with the `pauseOnHover` prop.

```astro
---
import { Marquee } from "@/components/ui/marquee"

const items = ["Tailwind CSS", "Bootstrap", "Sass", "PostCSS"]
---

<Marquee class="mask-x-from-95%" pauseOnHover>
  {items.map((item) => (
    <span class="text-muted-foreground text-sm">{item}</span>
  ))}
</Marquee>
```

## Styling

Set `infinite={false}` when you only want to render the slot once.

## API Reference

Read the [installed source](/r/marquee.json) for the complete prop types.

## When to use Marquee

Use Marquee for secondary visual content such as a short logo sequence. Set direction, duration, and gap through its props. Keep a readable static route to any information that matters.

## Keyboard and behavior

Motion must not prevent users from reading or activating content. Use the pause option where appropriate and test reduced-motion preferences. Repeated visual content should not cause repeated announcements or duplicate focus targets.

## Theme and layout

Check the loop boundary with the actual content widths. Large gaps and mismatched items can expose an empty region. Colors come from the children, so inspect logos against both theme backgrounds.
