Skip to content

News Ticker

Show a row of headline links beside a fixed "Latest news" label. pause-on-hover holds a headline still under the pointer, pause-button gives every reader a way to stop it, and fade softens both edges.

Keyboard focus on a headline link pauses the ticker and brings the headline into view.

Reduced Motion

Your system is set to reduce motion. The ticker does not move, and you can scroll it by hand.

Code

The following example assumes that you have imported the component and set up the theme.

News Ticker
<div class="news-ticker-example">
10 collapsed lines
<section class="news-ticker" aria-labelledby="news-ticker-label">
<span id="news-ticker-label" class="news-ticker-label">Latest news</span>
<sv-marquee class="news-ticker-headlines" fade pause-button pause-on-hover speed="60">
<a href="#">City council approves twelve new kilometers of bike lanes</a>
<a href="#">Local library opens its doors around the clock during exam season</a>
<a href="#">Harbor festival returns this weekend with a record lineup</a>
<a href="#">Weather service expects the first frost by Thursday night</a>
<a href="#">Tram line 4 runs on a weekend timetable until the end of May</a>
</sv-marquee>
</section>
</div>
<style>
53 collapsed lines
.news-ticker {
display: flex;
flex-wrap: wrap;
align-items: stretch;
overflow: hidden;
border: var(--sv-bdr-sz-sm) solid var(--sv-gray-5);
border-radius: var(--sv-bdr-rad-md);
}
.news-ticker-label {
display: flex;
flex: 1 0 auto;
align-items: center;
padding: 0.4em 0.75em;
font-size: 0.7rem;
font-weight: 700;
color: var(--sv-accent-content);
text-transform: uppercase;
letter-spacing: 0.04em;
white-space: nowrap;
background-color: var(--sv-accent);
}
.news-ticker-headlines {
--sv-marquee-gap: 1.5rem;
--sv-marquee-fade-sz: 2rem;
flex: 999 1 16rem;
align-self: center;
min-inline-size: 0;
padding-block: 0.4em;
padding-inline-end: 0.4em;
&::part(pause-button) {
font-size: 0.75rem;
}
a {
color: inherit;
white-space: nowrap;
text-decoration: none;
&:hover {
text-decoration: underline;
}
&::after {
margin-inline-start: 1.5rem;
color: var(--sv-gray-3);
content: "•" / "";
}
}
}
</style>