Skip to content

Carousel

Get Ritla UI

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

Open in Figma

Preview

Mirrored is the same English content laid out right to left: it separates a mirroring bug from a translation one.

PreviewCode
EnglishMirroredArabic
LTR →

Installation

  1. Add the component

    npx ritla add carousel

    Also works with shadcn: npx shadcn@latest add @ritla/carousel

  2. Dependencies it brings

    @phosphor-icons/react

  3. Or 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

carousel.tsx
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.

EnglishMirroredArabic
LTR →

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.

EnglishMirroredArabic
LTR →

API reference

Carousel

PropTypeDefaultDescription
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.
titleReactNodeNoneThe Cards heading beside the arrows, and the carousel's name.
labelstringNoneThe carousel's name for screen readers when there's no text title.
childrenCarouselSlide[]NoneThe slides: five or fewer, the most important first.

CarouselSlide

PropTypeDefaultDescription
iconIconComponentNoneCards: an icon in a rounded brand/faint box.
artworkReactNodeNoneSingle: the 180px artwork panel's content.
title / descriptionReactNodeNoneFigma's Heading and Body.
childrenReactNodeNoneAnything after the text: a link or button.

CarouselImage

PropTypeDefaultDescription
srcstringNoneThe photo; it fills the frame, cropped to cover it.
altstringNoneRequired: 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.

KeyAction
TabTo the arrows, the track, then the dots and the links inside slides.
EnterSpaceOn an arrow: one slide. On a dot: that slide.
ArrowLeftArrowRightOn 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-16 Semibold, body label-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.

  • R012Untranslated attribute text (placeholder, alt, title, aria-label, button value)
  • R042Clipped text: content wider than its box with overflow hidden and no ellipsis
  • R043Fixed-pixel-width container whose Arabic text exceeds the space
  • R050Arabic text falling back past the declared font family (measured, declared, or a webfont that failed to load)
  • R051letter-spacing applied to Arabic text (breaks the connected script)