Navigation
Carousel
A slide show with previous and next buttons, a slide picker and swipe on touch. Automatic rotation is opt-in and always stoppable.
import { Carousel } from '@reactloom/ui';Examples
Announcements
import { Carousel, Link, Stack, Text } from '@reactloom/ui';
const slides = [
{ title: 'Saved views', text: 'Keep a grid’s filters, sorting and columns as named views.', tone: 'accent' },
{ title: 'Event calendar', text: 'Create and move events with the keyboard as well as the mouse.', tone: 'success' },
{ title: 'Command palette', text: 'Search every action from one place with ⌘K.', tone: 'info' },
];
export default function Example() {
return (
<div style={{ inlineSize: '100%', maxInlineSize: 520 }}>
<Carousel aria-label="What’s new">
{slides.map((slide) => (
<Stack key={slide.title} gap="1" style={{ padding: 24, minBlockSize: 140, background: `var(--pl-color-${slide.tone}-subtle)` }}>
<Text weight="semibold" size="lg">
{slide.title}
</Text>
<Text>{slide.text}</Text>
<Link href="#examples">Read more</Link>
</Stack>
))}
</Carousel>
</div>
);
}Automatic rotation
Pauses on hover and focus, has a stop button, and never starts with reduced motion.
import { Carousel } from '@reactloom/ui';
const quotes = ['“The grid handles 50,000 rows without breaking a sweat.”', '“Our screen-reader users noticed the difference first.”', '“Theming took an afternoon.”'];
// Rotation stops on hover and focus, has a stop button, and never starts with reduced motion.
export default function Example() {
return (
<div style={{ inlineSize: '100%', maxInlineSize: 520 }}>
<Carousel aria-label="Customer quotes" autoPlay={5000} loop>
{quotes.map((quote) => (
<blockquote key={quote} style={{ margin: 0, padding: 24, minBlockSize: 80, background: 'var(--pl-color-bg-subtle)', fontSize: 18 }}>
{quote}
</blockquote>
))}
</Carousel>
</div>
);
}API reference
| Prop | Type | Default |
|---|---|---|
aria-labelrequiredName of the carousel. | string | — |
childrenrequiredOne child per slide. | ReactNode | — |
index / defaultIndex / onIndexChange | number | — |
loopNext after the last goes to the first. | boolean | false |
autoPlayRotate every n ms. | number | — |
showPickerSlide dots. | boolean | true |
messagesTranslate button and slide names. | Partial<CarouselMessages> | — |
Customization
Extracted from the component’s source on every build, so it matches the code. How the layers fit together is explained in Customization.
Theme tokens it reads
--pl-color-accent-solid --pl-color-fg-muted --pl-focus-ring-color --pl-focus-ring-width --pl-radius-full --pl-radius-md
Accessibility
- The carousel is a region with aria-roledescription="carousel"; slides are groups named “2 of 5”.
- Hidden slides are inert: their links are not in the tab order.
- Changes made by the user are announced; automatic changes are not.
| Key | Action |
|---|---|
| Tab | Controls, then the visible slide’s content |
| Enter / Space | Activate previous, next, a dot or pause |
Usage guidelines
Do
- Keep slides few and make each one useful on its own.
- Put the most important message first, or outside the carousel.
Don’t
- Don’t hide essential information in later slides.