Ir al contenido
Español
Marquesina infinita viene con Pro. La vista previa aparece al desbloquearlo.

Cómo funciona

The track holds two identical groups; a CSS animation moves it from 0 to -50%, exactly one group, and back seamlessly. Short content is repeated inside each group so there is never a gap. Duration is group length ÷ speed, measured again with a ResizeObserver, so the speed in pixels per second holds for any content; changing it keeps the current progress. Copies are aria-hidden and inert. The fade uses mask-image, so it works on any background.

Úsalo para

  • Showing partner names, logos or press mentions on a marketing page.
  • Decorative areas that rotate many tags in limited space.
  • A scrolling announcement strip at the top of a page (vertical).

Busca otra opción cuando

  • Important information people must read or click: moving content is easy to miss.
  • More than two on one screen: several moving areas distract.
  • Lists that people browse and compare item by item: use plain scrolling or a grid.

Uso

import { Marquee } from './Marquee.jsx'

export function Cities({ cities }) {
  return (
    <Marquee speed={40} direction="left" pauseOnHover fade>
      {cities.map((city) => (
        <CityTag key={city.id} city={city} />
      ))}
    </Marquee>
  )
}

// Vertical: give it a fixed height
<Marquee direction="up" style={{ height: 160 }}>{notices}</Marquee>

Propiedades

PropiedadTipoPor defectoQué hace
speednumber40Scroll speed in pixels per second, independent of content length.
direction'left' | 'right' | 'up' | 'down''left'Scroll direction. Vertical needs a fixed height on the component.
pauseOnHoverbooleantruePauses while the pointer is over it. Keyboard focus always pauses.
fadebooleantrueFades both ends with a mask.
fadeSizenumber48Length of the fade area in px.
gapnumber12Space between items in px, the same at the loop seam.
pausedbooleanfalsePauses from outside, for example from a “pause scrolling” button.
childrenReactNode—The scrolling content: a set of elements side by side.
...restHTMLAttributes—Other attributes go to the root element, such as className, style and role.

Accesibilidad

  • Only the first copy is visible to screen readers; the others are aria-hidden and inert, so nothing is read twice or reached by Tab.
  • Keyboard focus pauses it automatically, and the paused prop lets you add a pause button (WCAG 2.2.2).
  • Hover pause applies only on devices that can hover, so touch never gets stuck paused.
  • With reduced motion it does not scroll by itself, copies and fade are removed, and people scroll by hand.

Movimiento

Constant speed (linear, otherwise each loop would hitch at the seam); duration is group length ÷ speed. Changing speed keeps progress; hover or focus pauses instantly.

Añádelo a tu proyecto

Los miembros Pro copian un prompt y su agente de programación instala el código, igual que con los gratuitos.

Marquee.jsxmarquee.csstokens.cssREADME.md

Los dos archivos se instalan juntos. La hoja de estilos lee las variables de tokens.css y lleva valores de reserva, así que también funciona sola.

Listas
Carrusel en arco viene con Pro. La vista previa aparece al desbloquearlo.
Carrusel cilíndrico viene con Pro. La vista previa aparece al desbloquearlo.