Carousel
A row of slides you scroll or step through with buttons.
SourceStyles source@monoline/react 0.4.0Markdown for AI toolsstable
- Built on native elements
- 2 parts, named exports
- A named region with aria-roledescription="carousel"; each slide is a group named "N of M".
- Previous and Next are real buttons; the track is also scrollable by keyboard and touch.
- No auto-play, so nothing moves without the user.
- Styles in one file:
carousel.css
Import
import '@monoline/css';
import {Carousel} from '@monoline/react';
Not installed yet? Pick a route.
Copies the source and its styles into your project.
npx monoline add carousel
Usage
import {Carousel} from '@monoline/react';
<Carousel aria-label="Featured">
{['Alpha', 'Beta', 'Gamma', 'Delta'].map((n) => <div key={n} style={{display: 'grid', placeItems: 'center', height: '140px', border: '1px solid var(--rule)'}}>{n}</div>)}
</Carousel>
Anatomy
Import the parts you need and nest them like this.
import {Carousel, CarouselItem} from '@monoline/react';
<Carousel>
<CarouselItem />
</Carousel>
Examples
Cards
Props
CarouselProps
| Prop | Type | Default | Description |
|---|---|---|---|
aria-label required | string | – | Names the carousel, for example "Featured projects". |
Data Attributes
State is exposed through attributes. Style it with these selectors, not with class toggles.
This component sets no state attributes.
CSS classes
| Class | Stylesheet |
|---|---|
.carousel | carousel.css |
.carousel-controls | carousel.css |
.carousel-slide | carousel.css |
.carousel-track | carousel.css |
Customization
Style it with the kit's tokens in your own CSS, loaded after @monoline/css. Prefer the attributes above over extra classes. See Theming for every token.
app.css
.carousel {
border-color: var(--accent);
}
Accessibility
- A named region with aria-roledescription="carousel"; each slide is a group named "N of M".
- Previous and Next are real buttons; the track is also scrollable by keyboard and touch.
- No auto-play, so nothing moves without the user.