Carousel
A set of slides shown one step at a time: offers, onboarding and highlights. Arrows move one slide, dots show the position.
Ritla scan of this preview: 41 of 41 checks3 breakpointsScanned
Preview
Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.
Installation
Add the component
npx ritla add carouselAlso works with shadcn:
npx shadcn@latest add @ritla/carouselDependencies it brings
@phosphor-icons/reactOr copy by hand
Installing by hand copies the component's source into your project. The source comes with a Ritla UI license, so the CLI is the short way to the same files.
Usage
import { Carousel, CarouselSlide } from "@/components/ui/carousel";<Carousel title="Offers for you"> <CarouselSlide icon={CoinsIcon} title="Cashback on groceries" description="Get 5% back at partner stores this month." /> <CarouselSlide icon={AirplaneIcon} title="Travel insurance" description="Covered on every trip you pay with Demo Bank." /></Carousel>Examples
Single
type="single" for onboarding: one full-width slide, the arrows around the dots.
Slides with links
Tab moves through the links in order, and the track scrolls to keep the focused one in view.
Image
type="image": one 16:10 photo at a time, the glass arrows and the dots on it. size="lg" for a desktop hero. At either end the arrow goes and focus moves to the other one. Every CarouselImage takes alt text in the page language.
API reference
Carousel
| Prop | Type | Default | Description |
|---|---|---|---|
type | "cards" | "single" | "image" | "cards" | Figma's Type; image is the Carousel image set. |
size | "md" | "lg" | "md" | Figma's Size, with type="image": 36 or 44px arrows. |
title | ReactNode | None | The Cards heading beside the arrows, and the carousel's name. |
label | string | None | The carousel's name for screen readers when there's no text title. |
children | CarouselSlide[] | None | The slides: five or fewer, the most important first. |
CarouselSlide
| Prop | Type | Default | Description |
|---|---|---|---|
icon | IconComponent | None | Cards: an icon in a rounded brand/faint box. |
artwork | ReactNode | None | Single: the 180px artwork panel's content. |
title / description | ReactNode | None | Figma's Heading and Body. |
children | ReactNode | None | Anything after the text: a link or button. |
CarouselImage
| Prop | Type | Default | Description |
|---|---|---|---|
src | string | None | The photo; it fills the frame, cropped to cover it. |
alt | string | None | Required: what the photo shows, in the page language. |
Accessibility
Keyboard
Keys are written for left-to-right. In right-to-left the arrow keys swap: the one pointing toward the reading direction moves forward.
| Key | Action |
|---|---|
| Tab | To the arrows, the track, then the dots and the links inside slides. |
| EnterSpace | On an arrow: one slide. On a dot: that slide. |
| ArrowLeftArrowRight | On the track: native scrolling. |
ARIA
- The carousel is a named region (
aria-roledescription"carousel"); each slide is a group named "2 of 4". - The arrows are "Previous slide" and "Next slide" and turn off at the ends (in the image carousel they go, after handing focus to the other arrow). The dots are "Go to slide 2" buttons.
- Moving with the buttons is announced politely ("Slide 2 of 4"). No auto play.
Arabic and RTL notes
Mirrors
- Slides start on the right, and so does the active dot.
- The right-pointing arrow goes to the previous slide, and swiping follows the reading direction.
- Directional artwork icons (the paper plane) mirror.
Does not mirror
- Non-directional icons (coins, piggy bank) don't mirror.
- Numerals
- Slide names and figures in the text follow the numerals setting.
- Arabic typography
- Heading
label-16Semibold, bodylabel-14. - Mixed-direction text
- Ritla UI uses native scrolling, so the browser handles the scroll direction in Arabic with no hand-made maths.
Checks it passes
The Ritla checks this component satisfies by construction. Used as documented, it does not bring these defects onto your page.
- Untranslated attribute text (placeholder, alt, title, aria-label, button value)
- Clipped text: content wider than its box with overflow hidden and no ellipsis
- Fixed-pixel-width container whose Arabic text exceeds the space
- Arabic text falling back past the declared font family (measured, declared, or a webfont that failed to load)
- letter-spacing applied to Arabic text (breaks the connected script)