HextaUI

Carousel: Right to left

Slides start on the right, the arrows flip, the Left arrow key moves forward and the dots fill from the right.

import {
  Carousel,
  CarouselContent,
  CarouselCounter,
  CarouselDots,
  CarouselItem,
  CarouselNext,
  CarouselPrevious,
} from "@/components/ui/carousel"

const slides = [1, 2, 3, 4, 5]

export function CarouselRtl() {
  return (
    <div dir="rtl" className="w-full max-w-md px-12">
      <Carousel autoplay={{ delay: 4000 }} aria-label="شرائح">
        <CarouselContent>
          {slides.map((value) => (
            <CarouselItem key={value} className="basis-1/2">
              <div className="flex aspect-square items-center justify-center rounded-xl border bg-card p-6 text-4xl font-semibold">
                {value}
              </div>
            </CarouselItem>
          ))}
        </CarouselContent>
        <CarouselPrevious />
        <CarouselNext />
        <div className="mt-3 flex items-center justify-between">
          <CarouselCounter />
          <CarouselDots />
        </div>
      </Carousel>
    </div>
  )
}

This adds the example as components/examples/carousel/rtl.tsx, together with the Carousel component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/carousel-rtl.json

To add only the component, follow the Carousel installation.

Props in this example

The Carousel props this example sets, from the API reference.

PropTypeDefault
autoplayAdvance on a timer. delay defaults to 5000ms, minimum 1000ms.
boolean | { delay?: number }false

Every prop is in the Carousel API reference.

See them all, with keyboard support and accessibility notes, on the Carousel page.