Saltar al contenido
DS

Componentes · Interacción

Marquesina <Marquee>

Una cinta que se mueve sola (logos, prensa) y se para si el usuario lo pide.

import Marquee from '@vivla-cms/ds/primitives/Marquee.astro'

Ejemplos

Cinta de destinos

Un bucle continuo en CSS: el contenido se pinta dos veces (la copia, oculta a lectores de pantalla e inalcanzable con el teclado). Aparece un botón de pausa de 44 px porque un movimiento de más de 5 s tiene que poder pararse (WCAG 2.2.2); con «reducir movimiento» del sistema no se mueve. Se para también al pasar el ratón y al enfocar algo dentro.

IbizaMenorcaMallorcaBaqueiraCerdanyaCosta BravaSotograndeMarbella

Logos de socios

gap separa los elementos (sm, md, lg) y speed son los segundos que tarda una vuelta: cuanto más alto, más lento. Los logos van en el color del texto con un filtro, nunca recoloreados a mano.

andbanksavillsengellucas-foxfasanarafj-labssamaipataenisa

Dirección y velocidad

direction="right" invierte el sentido. Dos cintas en sentidos opuestos y velocidades distintas (speed 20 y 60) dan profundidad. pauseOnHover={false} sigue moviéndose bajo el ratón (el foco del teclado la sigue parando).

Tu segunda casa ·1/8 ·Seis semanas al año ·Sin preocupaciones ·De 1/8 a 1/2 ·
Tu segunda casa ·1/8 ·Seis semanas al año ·Sin preocupaciones ·De 1/8 a 1/2 ·

Alineada con el texto

Con inset la cinta empieza en el margen de la página, alineada con el titular de encima, y aun así se escapa hasta el borde de la pantalla al moverse.

Dónde estamos

IbizaMenorcaMallorcaBaqueiraCerdanyaCosta Brava

Sin botón de pausa (landings)

controls={false} quita el botón de pausa: la fila de fotos y la banda de prensa de las landings van así (15/10, «hay que quitar los plays»). Se sigue parando al pasar el ratón o al enfocar algo dentro, y no se mueve con «reducir movimiento». gap="none" junta las piezas, para fotos que se tocan.

Props

Props de Marquee
Prop Valores Por defecto Para qué
speed number 30 Seconds per loop.
direction leftright 'left' —
pauseOnHover boolean true —
gap nonesmmdlg 'md' Gap between items, in Tailwind gap steps (gap-10 = 2.5rem).
label string — —
controlClass string '' Classes of the row that holds the pause button (flex), e.g. justify-end px-gutter.
inset boolean false The row starts at the page margin, where a Container starts (the first item lines up with the section title above it, on any screen width) and still drifts out to the screen edge: the gutter is padding inside the clipped viewport, so nothing is cut at the margin. (Until 05/11 it also added half of what the viewport exceeded the 1512 canvas by, to follow the capped container; the page has no cap any more.)
controls boolean true Render the pause/play button (default true). false = a loop with no button (landings' photo row and press band — Jorge, 15/10: «hay que quitar los plays»); pointer hover and keyboard focus still pause it.

Slots: contenido

Notas del código

El comentario de cabecera de Marquee.astro, tal cual (en inglés, como el código): si cambia el código, cambia esto.

continuous horizontal scroll (logo clouds, destination names). Pure CSS loop: the slot is rendered twice and each copy translated by -100 %, so it is seamless as long as the content is wider than the viewport.

Accessibility:

  • The duplicate copy is aria-hidden AND inert, so its links are neither
announced nor reachable twice with the keyboard.
  • WCAG 2.2.2: motion that lasts more than 5 s needs a pause control. A
pause/play button (fixed label "Pause motion", state in aria-pressed) is
rendered `hidden` and revealed by the script, so no-JS visitors only get
the CSS loop, which `prefers-reduced-motion` already stops (base.css).
It is the DS icon button (`Button variant="secondary" size="icon"`, 56 px,
outlined in `line-strong`) with the pause / play glyph as the state cue;
`controlClass` places its row (e.g. `justify-end px-gutter` to sit inside
the page gutter at the right of a full-bleed strip).
  • pauseOnHover also pauses while the pointer is over the track, and
keyboard focus inside the track always pauses it.
  • The loop CSS lives in base.css (.ds-marquee*), not a scoped <style>:
component styles of a package primitive imported through a renderer do
not always reach the page in dev.

Dónde se usa

11 veces en 8 archivos de la web y los bloques del CMS.

Ver los archivos
esc