Catalog · Content
Marquee
Moves a line of short phrases, links or logos along the page and loops it, between two hairlines, as a decoration.
Fits best: landing — a ticker of short phrases or a band of logos on the page of a product or an event
Example
Two marquees: a ticker of five short phrases, and a showcase of four invented sites.
Each marquee stops while the pointer is over it or something in it has the focus, and it stays still when the reader asks for reduced motion. LUZ ships no logos: the marks here are drawn for the example, and the names are made up.
Known issues
On a touch screen there is no hover, so nothing stops the marquee except focusing a link. WCAG 2.2 success criterion 2.2.2 (Pause, Stop, Hide, level A) asks for a way to pause moving content that lasts more than five seconds, and the marquee has no button: it is not met there. A marquee only suits a decoration whose content is also somewhere else on the page.
A marquee should hold nothing the reader must read once and cannot return to: a price, a deadline, a warning.
Code
Copy the markup
import "@luz-ds/catalog/components/marquee.css";
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@luz-ds/catalog@0.5.1/dist/components/marquee.min.css" integrity="sha384-7kmcbgU1WnDcRrNKSRF04MrRZhsG8XW68zCyuG2+z0TPjKmkw/ntxD1q02ggJmi/" crossorigin="anonymous">
A <luz-marquee> around two copies of the same content. The second copy is aria-hidden="true", and each link in it has tabindex="-1". Link components/marquee.css of @luz-ds/catalog after core.
A ticker of short phrases is a <ul> of <li>:
<luz-marquee>
<ul>
<li>Zero dependencies</li>
<li>Native HTML first</li>
<li>MIT, and only MIT</li>
</ul>
<ul aria-hidden="true">
<li>Zero dependencies</li>
<li>Native HTML first</li>
<li>MIT, and only MIT</li>
</ul>
</luz-marquee>
To make a row of logos move, put a <luz-showcase> in it, twice:
<luz-marquee>
<luz-showcase>
<ul>
<li><a href="https://greenleaf.example/"><svg aria-hidden="true">…</svg><span>Greenleaf</span></a></li>
<li><a href="https://tidewater.example/"><svg aria-hidden="true">…</svg><span>Tidewater</span></a></li>
</ul>
</luz-showcase>
<luz-showcase aria-hidden="true">
<ul>
<li><a tabindex="-1" href="https://greenleaf.example/"><svg aria-hidden="true">…</svg><span>Greenleaf</span></a></li>
<li><a tabindex="-1" href="https://tidewater.example/"><svg aria-hidden="true">…</svg><span>Tidewater</span></a></li>
</ul>
</luz-showcase>
</luz-marquee>
Variants and options
| Tag, child or property | Effect |
|---|---|
<luz-marquee> | Around the content written twice. It moves along one line and loops, between two hairlines, and fades at both ends. A tag that no script defines: no class, no role of its own |
<ul> | A child that is a list is a row of short phrases, in the primary text colour, with a small decorative star between them |
<luz-showcase> | A child that is another tag keeps its own look: a row of links with a logo and a name, which moves as one line |
aria-hidden="true" | On the second child, the copy. It is hidden from assistive technology and, under reduced motion and on paper, not shown. A link in it has tabindex="-1" |
--luz-marquee-duration | On the tag, how long one loop takes. The default is 40 s, which is calc(var(--luz-duration-lazy) * 50). A longer list needs more time, so it moves at the same speed |
How it works
CSS from components/marquee.css of @luz-ds/catalog. No JavaScript: <luz-marquee> is a tag that no script ever defines.
- The tag hides what overflows, and a mask fades both ends. Two 1 px hairlines in
--luz-dividerframe it, above and below. - Each copy never wraps and moves left by its own width, then starts again, so the loop has no seam. Between the end of one copy and the start of the next there is the same gap as between two items.
- A copy that is a list is a row of phrases with a star after each one. The star is generated content with an empty text alternative, so a screen reader does not read it.
- The copy is not
inert: a pointer can still click a link in it, while the keyboard and a screen reader meet each link once. - It stops while the pointer is over it or something in it has the focus.
- Under reduced motion and on paper it does not move: the first copy is shown alone, wrapped and centred, with no fade.
- In a right-to-left page it runs the other way, from right to left.
Without JavaScript
Nothing changes: there is no script, and the marquee is CSS.
Keyboard and ARIA
- Tab: moves through the links of the first copy, in source order, each once. A ticker of phrases has nothing to focus. The links of the copy have
tabindex="-1". - Pause: the focus on a link stops the marquee, and moving it away starts it again. Nothing else on the keyboard stops it.
- The copy:
aria-hidden="true"hides it from a screen reader, which reads the first list once, as a list. Do not useinert, which would also stop the pointer. - The star: decoration, with no text to read.
- Not tested with a screen reader.
Contrast and focus are in the Design tab.
Design
When to use
Use it for a decoration that adds a little life to a page: a ticker of the product’s promises, the names of the sites built with it, the sponsors of an event.
- Use it when everything it says is also elsewhere on the page.
- Write short phrases, one idea each, that mean something on their own and in any order.
When not to use
Do not use it for anything the reader must read once and cannot return to, or for the links the page needs.
- Do not put a price, a deadline or a warning in it. For a notice that every visitor must see, use an announcement.
- Do not use it as the navigation: for the links of the site, use site-footer or the navbar.
- If the row of logos can stay still, keep it still: a showcase alone is easier to read and has no motion to stop.
Do and don't
<luz-marquee>
<ul>
<li>Native HTML first</li>
</ul>
<ul aria-hidden="true">
<li>Native HTML first</li>
</ul>
</luz-marquee>
<luz-marquee>
<ul>
<li>Native HTML first</li>
</ul>
<ul>
<li>Native HTML first</li>
</ul>
</luz-marquee>
aria-hidden="true" and take its links out of the Tab order with tabindex="-1": a pointer can still click them.<ul aria-hidden="true">
<li><a tabindex="-1" href="https://greenleaf.example/">Greenleaf</a></li>
</ul>
inert: it also stops the pointer, so a link that passes under it cannot be clicked.<ul inert>
<li><a href="https://greenleaf.example/">Greenleaf</a></li>
</ul>
<p>LUZ has zero dependencies and is MIT, and only MIT.</p>
<luz-marquee>…</luz-marquee>
<luz-marquee>
<ul>
<li>Sale ends on Friday at 18:00</li>
</ul>
…
</luz-marquee>
Writing the content
A phrase is short and complete, and it reads the same wherever the loop starts.
- Write two to six words, such as “Native HTML first”, not a sentence with a full stop.
- Write five to eight phrases. A longer list needs a longer
--luz-marquee-duration, so it keeps the same speed. - Write the same phrases, in the same order, in both copies.
- Put a
langon a phrase in another language than the page.
Contrast and focus
The phrases take the primary text colour and the star the brand colour. The marquee has no surface of its own: it sits on the one the page gives it. The two hairlines only frame the band: they are decoration, and nothing depends on them. A showcase inside it has its own contrast.
| Part | Colour on background | Light | Dark | High contrast | Needs |
|---|---|---|---|---|---|
Phrase | --luz-text-primary on --luz-surface-page | 15.8:1 | 15.1:1 | 21.0:1 | 4.5:1 |
Phrase on a muted band | --luz-text-primary on --luz-surface-muted | 15.8:1 | 15.1:1 | 20.1:1 | 4.5:1 |
Star between phrases | --luz-brand-primary on --luz-surface-page | 5.6:1 | 7.7:1 | 14.1:1 | 3:1 |
Focus ring | --luz-focus-ring on --luz-surface-page | 5.6:1 | 7.7:1 | 21.0:1 | 3:1 |
Measured from the token values of each mode, rounded down. Needs is the WCAG 2.2 AA minimum: 4.5:1 for text, 3:1 for focus rings and for graphics. The star is decoration, so it has no minimum of its own.
- Focus: a link in the first copy keeps core’s 2 px
--luz-focus-ringoutline, and the focus stops the marquee. - The star is never the only signal: it only separates phrases that are already text.
Tokens it uses
The 10 tokens that the rules of catalog’s components/marquee.css read, by family. Each family links to its page, with the values in every mode. In Figma they are variables with the same names: see Tokens in Figma.
- Spacing and sizing
--luz-space-md,--luz-space-sm,--luz-space-xl- Typography
--luz-font-sans,--luz-text-lg,--luz-text-sm- Motion
--luz-duration-lazy
Keyboard and ARIA are in the Code tab.