Skip to content

Early previewhamur is not on npm yet. The components are being built in the open, follow along on GitHub.

UIComponentsReact

Marquee

A strip of content that scrolls on its own in a loop, such as news headlines or logos, with a button that stops and starts it.

Built on the headless Marquee.See its API in Docs

Rendered by React 19.3.1

marquee.tsx

Installation

npx shadcn@4.23.0 add https://hamur.dev/r/react/marquee.json

It also adds utils, button. The app needs its setup first: Installation.

Usage

Put a MarqueePlayControl and a MarqueeViewport inside Marquee, and a MarqueeContent holding the items inside the Viewport. Give the Marquee a name (aria-label or aria-labelledby). The Content is drawn as many times as it takes to fill the Viewport, so the loop has no gap; the copies are hidden from assistive technology and out of the tab order. Render the Content as a list with render when the items are one. The motion holds while the pointer is over the strip or a finger presses it, stops when keyboard focus enters it, and starts stopped under prefers-reduced-motion. speed (CSS pixels per second), reverse, orientation, loopCount, overflowOnly, playing, labels, onPlayingChange and onComplete come from the headless Marquee.

import {
  Marquee,
  MarqueeContent,
  MarqueePlayControl,
  MarqueeViewport,
} from '@/components/ui/marquee'

Examples

Default

A strip of headline links with a button that stops and starts the loop.

Its preview and code are at the top of the page.

Content that moves on its own for more than five seconds needs a way to stop it (WCAG 2.2.2), so keep the PlayControl. It is the Button's outline icon-sm, 32 by 32 CSS pixels (WCAG 2.5.8), with a focus ring (WCAG 2.4.7); it shows a pause icon while the strip moves and a play icon otherwise, hidden from assistive technology, and is named by what a press does ("Pause scrolling", "Start scrolling"). The Viewport fades its content out over 2rem at both ends, the same in right-to-left text, and its gap is the space between the copies; the items inside the Content take the same gap. A focused item gets a ring too. A vertical Marquee needs a height on its Viewport. The strip is not announced as it moves. This item takes Base UI's component ID as its slug and one name per Base UI part.

API reference

The styled parts pass every prop to the headless part they wrap and add classes. The props, data attributes and keyboard are on Marquee's API reference.