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.
---
import Marquee from '@vivla-cms/ds/primitives/Marquee.astro'
const places = ['Ibiza', 'Menorca', 'Mallorca', 'Baqueira', 'Cerdanya', 'Costa Brava', 'Sotogrande', 'Marbella']
---
<div class="py-10">
<Marquee label="Nuestros destinos" controlClass="justify-end px-6 md:px-10 mt-6">
{places.map((place) => <span class="font-display text-h2 whitespace-nowrap">{place}</span>)}
</Marquee>
</div> 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.
---
import Marquee from '@vivla-cms/ds/primitives/Marquee.astro'
const logos = ['andbank', 'savills', 'engel', 'lucas-fox', 'fasanara', 'fj-labs', 'samaipata', 'enisa']
---
<div class="py-10">
<Marquee label="Confían en VIVLA" gap="lg" speed={45} controlClass="justify-end px-6 md:px-10 mt-6">
{logos.map((logo) => <img src={`/partners/${logo}-logo.svg`} alt={logo} class="h-8 w-auto opacity-80" />)}
</Marquee>
</div> 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).
---
import Marquee from '@vivla-cms/ds/primitives/Marquee.astro'
const words = ['Tu segunda casa', '1/8', 'Seis semanas al año', 'Sin preocupaciones', 'De 1/8 a 1/2']
---
<div class="flex flex-col gap-6 py-10">
<Marquee label="VIVLA, rápido" speed={20} gap="sm" pauseOnHover={false} controlClass="justify-end px-6 md:px-10 mt-4">
{words.map((w) => <span class="font-display text-h3 whitespace-nowrap">{w} ·</span>)}
</Marquee>
<Marquee label="VIVLA, lento" speed={60} direction="right" controlClass="justify-end px-6 md:px-10 mt-4">
{words.map((w) => <span class="text-lead whitespace-nowrap text-on-surface-muted">{w} ·</span>)}
</Marquee>
</div> 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
---
import Heading from '@vivla-cms/ds/primitives/Heading.astro'
import Marquee from '@vivla-cms/ds/primitives/Marquee.astro'
const places = ['Ibiza', 'Menorca', 'Mallorca', 'Baqueira', 'Cerdanya', 'Costa Brava']
---
<div class="flex flex-col gap-8 py-10">
<Heading level={3} class="px-gutter">Dónde estamos</Heading>
<Marquee label="Destinos" inset controlClass="justify-end px-gutter mt-4">
{places.map((place) => <span class="text-lead whitespace-nowrap">{place}</span>)}
</Marquee>
</div> 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.
---
import Marquee from '@vivla-cms/ds/primitives/Marquee.astro'
import Media from '@vivla-cms/ds/primitives/Media.astro'
const photos = [1, 2, 3, 4, 5].map((n) => `/assets/about/collage-${n}-640.webp`)
---
<div class="py-10">
<Marquee label="Fotos de las casas" controls={false} gap="none" speed={50}>
{photos.map((src) => <Media src={src} alt="" aspect="4/5" class="w-56 shrink-0" />)}
</Marquee>
</div> Props
| 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-hiddenANDinert, 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). pauseOnHoveralso 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
- packages/cms-blocks/src/renderers/LogoCloud.astro ×3
- apps/web/src/layouts/chrome/Nav.astro ×2
- apps/web/src/pages/dev/kit.astro ×1
- packages/cms-blocks/src/renderers/LandingHero.astro ×1
- packages/cms-blocks/src/renderers/LandingPress.astro ×1
- packages/cms-blocks/src/renderers/MediaCollage/catalog.astro ×1
- packages/cms-blocks/src/renderers/MediaCollage/drift.astro ×1
- packages/cms-blocks/src/renderers/parts/CardRail.astro ×1