Demos

A row of items scrolling left, with faded edges.

Usage

Use a marquee for content that is nice to glance at but not needed to complete a task: partner logos, member reviews, the list of biomarkers we test. Never put the only copy of important information or controls in a marquee, because it moves on its own and is hard to read and click.

Import it from @workspace/ui/components/marquee.

Anatomy

  • Marquee — The root. Sets the direction, speed and gap, and clips the moving content.
  • MarqueeContent — The moving track. It is duplicated so the loop has no gap.
  • MarqueeItem — One item in the track.
  • MarqueeEdge — A gradient that fades the content into the background at one side.

Notes

  • Give the root an aria-label. The duplicate copies of the content are hidden from screen readers.
  • speed is in pixels per second, so the pace stays the same whatever the content length.
  • Set autoFill when the content is shorter than the marquee, so it repeats enough times to fill it.
  • For a vertical marquee (side="top" or side="bottom"), give the root or its parent a height.
  • The animation stops when the reader prefers reduced motion.
  • Turn on pauseOnHover or pauseOnKeyboard whenever items are worth reading, so people can stop the motion.

Examples

Vertical

Set side="top" or side="bottom" to scroll up or down.

Pause on hover

Set pauseOnHover to stop while the pointer is over the marquee, and pauseOnKeyboard to let people focus it and press Space to pause and resume.

Reverse

Set reverse to run the other way. Rows moving in opposite directions work well together.

Props

These are the props you set most often. Unlisted props pass through to the underlying element.

Marquee

PropTypeDefaultDescription
side"left", "right", "top" or "bottom""left"The direction the content moves toward.
speednumber50Speed in pixels per second.
gapstring"1rem"Space between items and between copies, as a CSS length.
delaynumber0Seconds to wait before starting.
loopCountnumber0Number of loops. 0 loops forever.
autoFillbooleanfalseRepeat the content to fill the marquee.
pauseOnHoverbooleanfalsePause while the pointer is over it.
pauseOnKeyboardbooleanfalseMake it focusable and toggle pause with Space.
reversebooleanfalseRun the animation the other way.
dir"ltr" or "rtl"InheritedText direction. Defaults to the nearest direction provider.
renderReactElement or function—Replaces the root div with your own element.
classNamestring—Classes merged onto the root.

MarqueeEdge

PropTypeDefaultDescription
side"left", "right", "top" or "bottom"—The side to fade.
size"sm", "default" or "lg""default"Width (or height) of the fade: a sixth, a quarter or a third.