shadcn.io is not affiliated with official shadcn/ui
Rotating Carousel Banner Block for React
A rotating announcement for a design-system library in a framed figure: three slides cross-fade in one place, with a Pause button, pause on hover and focus, and dots that name their slide.
Installation
Overview
An announcement rotator for React with Base UI, for a slot that carries more than one message. A framed card with + marks on its corners holds three slides, each a badge, a headline and an underlined link, that cross-fade in one place every six seconds. Every slide sits in the same grid cell, so the card never changes height. A Pause button comes first in the card, the dots at the foot are real buttons that say which update they show, and rotation stops while the pointer is over the card or keyboard focus is inside it. It never starts by itself under reduced motion. It's built from Badge, Button and Guides, with CSS for every transition and your theme's tokens for every colour. For release notes, events and docs news above a hero.
FAQ
Why does it have a Pause button, and when does it stop on its own?
Anything that moves by itself for more than five seconds has to be pausable (WCAG 2.2.2), so the Pause button is the first control in the card, before the moving content, and it flips to Play. Rotation also holds while the pointer is over the card and while keyboard focus is inside it, so a slide is never taken away mid-read. A click that focuses a dot does not hold it: only keyboard focus does. With reduced motion turned on it starts paused, and Play starts it.
How do I change the speed or the slides?
Edit ROTATION_MS for the pause between slides (5000 to 8000 reads well), and SLIDES for the content: each entry is a badge, a title, a link and an href. The dots, their labels ("Show update 2 of 3") and the rotation follow the list, and choosing a dot restarts the wait for that slide.
Does a screen reader hear every slide change?
No: while it rotates, the slides are not announced, because a message that changes every six seconds would talk over everything else. Once it is paused, the region is polite, so choosing a dot reads the slide you chose. Slides that are not showing are inert and hidden from assistive technology, and their links cannot take focus.
Why doesn't the card jump when the slide changes?
All slides share one grid cell, and the cell is as tall as the tallest, so a longer headline on one slide never moves the page. Keep headlines to about the same length, and write them so the card stays under about 330 pixels.
Related
- Pro
Tabbed Carousel Banner
Disclosures and tabsA tabbed announcement for a documentation platform: a card with three underline tabs (What's new, Tips, Updates) and a panel under them, driven by the visitor, with no autoplay.
- Pro
Scroll Marquee Banner
TickersA news ticker for a developer platform on a tinted strip: a Latest label, a labelled Pause button, and eight headline links with a bold lead scrolling past.
- 010203Pro
Numbered Announcements Banner
Numbered listsA weekly digest band for a product-updates tool: a quiet title and count, then three numbered announcements on hairlines, each row one link with a trailing arrow.
- v4.2123Pro
Numbered Changelog Banner
Numbered listsA release banner for a release-management tool: the latest version set large at the start, and the three before it as a numbered list at the end, split by a solid divider.
- Pro
Top Bar Banner
Top barsA slim announcement strip for a writing app's release: one centred line with the version, the news and an underlined link, and a ghost button that folds the strip away.
- Pro
Expandable Banner
Disclosures and tabsA fee-change notice for a rent-collection tool as a card in card: one header line that opens a sentence, three rows of facts (Now, From next renewal, Why) and a link.