Marquee
Endless horizontal strip that loops its children, pauses on hover and focus, and can fade out at both edges.
pnpm dlx shadcn@latest add @haze/marquee---
import { cn } from "../../../lib/haze/utils";
interface Props {
/** Seconds for one full loop. Higher is slower. */
duration?: number;
gap?: "sm" | "md" | "lg";
/** Soft transparent edges on both sides. */
fade?: boolean;
class?: string;
}
const { duration = 40, gap = "md", fade = false, class: className } = Astro.props;
// Gap and trailing padding match, so the seam between the two copies is the same as every other gap.
const gaps = { sm: "gap-4 pr-4", md: "gap-8 pr-8", lg: "gap-12 pr-12" };
// Under reduced motion the track stops, so each copy wraps and fits the box instead of being clipped.
const copy = cn("flex shrink-0 items-center motion-reduce:shrink motion-reduce:flex-wrap motion-reduce:justify-center", gaps[gap]);
---
<div
class={cn(
"group overflow-hidden",
fade && "[mask-image:linear-gradient(to_right,transparent,black_12%,black_88%,transparent)] motion-reduce:[mask-image:none]",
className,
)}
>
<div
class="flex w-max animate-marquee motion-reduce:w-auto motion-reduce:flex-wrap motion-reduce:justify-center group-hover:[animation-play-state:paused] group-focus-within:[animation-play-state:paused]"
style={`animation-duration: ${duration}s`}
>
<div class={copy}><slot /></div>
<div class={cn(copy, "motion-reduce:hidden")} aria-hidden="true" inert><slot /></div>
</div>
</div>When to use
- A decorative strip of customer names or logos under a hero
- A row of short tags or integrations where seeing all of them at once is not required
- Many items that would not fit in one row on a narrow screen
When not to use
- Anything people must read, such as prices, steps or legal text; moving text is hard to read and to stop
- A page that needs a visible pause button; this component has none and pauses only on hover and keyboard focus
- Navigation or interactive content; the second copy is hidden from assistive technology
Installation
Add the Haze registry to components.json once, then install Marquee with the shadcn CLI. Works in any Astro project with Tailwind CSS v4.
pnpm dlx shadcn@latest add @haze/marqueenpx shadcn@latest add @haze/marqueeyarn dlx shadcn@latest add @haze/marqueebunx --bun shadcn@latest add @haze/marqueeFirst time? Registry and theme setup
1. Add to components.json:
{
"registries": {
"@haze": "http://localhost:4329/r/{name}.json"
}
}2. Install the theme once: npx shadcn@latest add @haze/theme, then import it after Tailwind in your global CSS:@import "./haze.css";
API reference
| Prop | Type | Default | Description |
|---|---|---|---|
| duration | number | 40 | Seconds for one full loop, set as an inline animation-duration. |
| gap | "sm" | "md" | "lg" | "md" | Space between items: 16, 32 or 48 px. The same value pads the end of each copy so the loop has no jump. |
| fade | boolean | false | Softens both edges with a CSS mask that goes from transparent to black. |
| class | string | – | Extra classes on the clipping box. |
| default slot* | slot | – | The items. The slot is rendered twice; the second copy is aria-hidden and inert. |
Accessibility
- Moving content that lasts more than 5 seconds needs a way to pause it (WCAG 2.2.2). This strip pauses only on hover and keyboard focus inside it, with no button, so use it for decoration only.
- The theme turns the animation off under prefers-reduced-motion; the track then wraps into centered rows that fit the box, the duplicate copy is hidden and the edge fade is removed, so every item stays visible.
- The duplicate copy is aria-hidden and inert, so a screen reader reads each item once and keyboard focus never lands in it; keep focusable controls out of the strip.
Notes for AI
Copy into Claude Code, Cursor, Codex or any coding agent. Agents can also read the Markdown version of this page.
Install and use
Install the Haze UI component "Marquee" with `npx shadcn@latest add @haze/marquee`. If components.json has no "@haze" registry yet, add "registries": { "@haze": "http://localhost:4329/r/{name}.json" }. If src/styles/haze.css does not exist yet, run `npx shadcn@latest add @haze/theme` once and import it from the global stylesheet after Tailwind. The CLI stops at an overwrite question when a Haze file already exists and differs, even with --yes, and then installs nothing after it: read its output. If the user has not edited their Haze files, re-run with --overwrite to take the registry versions; if they have, ask them before overwriting. Then import Marquee from "@/components/haze/ui/marquee.astro" (or the relative path) and render it where it fits the page. Keep Haze token classes (bg-background, text-muted-foreground, border-border...) and never hardcode colors. Docs: http://localhost:4329/ui/marquee.md
Customize with real content
Adapt the Haze marquee ui for our product. Replace the demo values of these props with our real content: duration, gap, fade, class, default slot. Keep the layout, the heading level rules and these accessibility details: Moving content that lasts more than 5 seconds needs a way to pause it (WCAG 2.2.2). This strip pauses only on hover and keyboard focus inside it, with no button, so use it for decoration only. The theme turns the animation off under prefers-reduced-motion; the track then wraps into centered rows that fit the box, the duplicate copy is hidden and the edge fade is removed, so every item stays visible. The duplicate copy is aria-hidden and inert, so a screen reader reads each item once and keyboard focus never lands in it; keep focusable controls out of the strip. Do not add raw color classes; use the Haze tokens.
Choose the right block
Before using marquee, check it fits: use it when a decorative strip of customer names or logos under a hero; a row of short tags or integrations where seeing all of them at once is not required; many items that would not fit in one row on a narrow screen. Avoid it when anything people must read, such as prices, steps or legal text; moving text is hard to read and to stop; a page that needs a visible pause button; this component has none and pauses only on hover and keyboard focus; navigation or interactive content; the second copy is hidden from assistive technology. Alternatives: @haze/logo-mark, @haze/badge.
Dependencies
- @haze/utils
- @haze/theme (one-time setup)
Source · Original Haze UI work.