Layout

Carousel

A touch-friendly, accessible slideshow for cycling through items, powered by Embla.

Preview
01 Installation

Install

Pull Carousel from the barrel for everyday use, or the granular path when you want a tighter bundle.

tsxBarrel1 line
import { Carousel } from "@brika/clay";
tsxGranular1 line
import { Carousel } from "@brika/clay/components/carousel";
02 Usage

A minimal example

Drop this into a page. Native HTML attributes pass through to the underlying primitive.

tsxCarousel.tsx29 lines
import { Card, CardContent } from '@brika/clay/components/card';
import {
  Carousel,
  CarouselContent,
  CarouselItem,
  CarouselNext,
  CarouselPrevious,
} from '@brika/clay/components/carousel';
const SLIDES_5 = [1, 2, 3, 4, 5] as const;

export default function CarouselDefaultDemo() {
  return (
    <Carousel className="w-full max-w-xs">
      <CarouselContent>
        {SLIDES_5.map((n) => (
          <CarouselItem key={n}>
            <Card>
              <CardContent className="flex aspect-square items-center justify-center p-6">
                <span className="font-semibold text-4xl">{n}</span>
              </CardContent>
            </Card>
          </CarouselItem>
        ))}
      </CarouselContent>
      <CarouselPrevious />
      <CarouselNext />
    </Carousel>
  );
}
03 Examples

Carousel, every way

Multiple

04 Accessibility

Accessibility

  • Root carries role="region" with a label; each slide has role="group" aria-roledescription="slide".
  • Previous/Next buttons include sr-only screen-reader labels.
  • Left/Right arrow keys navigate slides while focus is inside the carousel.
  • Autoplay should pause on hover and focus to respect user attention and prefers-reduced-motion.
05 API reference

API reference

Props specific to Carousel. Native HTML attributes pass through to the underlying primitive, see the component source on GitHub for the full type signature.

4 props
  • CarouselOptions
    Embla carousel options (e.g. { loop: true, align: 'start' }).
  • orientationdefault 'horizontal'
    'horizontal' | 'vertical'
    Scroll axis, "horizontal" (default) or "vertical".
  • CarouselPlugin
    Embla plugins (e.g. Autoplay).
  • (api: CarouselApi) => void
    Callback that receives the Embla API instance once initialized.

<CarouselContent />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<CarouselContext />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<CarouselItem />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<CarouselNext />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.

<CarouselPrevious />

passthrough

No wrapper-specific props, all attributes pass through to the underlying primitive.