Skip to content
SevenOne

Search documentation

Search pages and components

CarouselPro

Slides you move with 44px round buttons (48px in Large mode), swipe or the arrow keys. One per view, several per view, or vertical. Built on Embla. It never moves on its own.

Installation

This component is part of SevenOne Pro.

The Pro license includes the code of every Pro component, the complete Figma file and the Angular version.

Usage

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

<Carousel aria-label="Featured items">
  <CarouselContent>
    <CarouselItem>...</CarouselItem>
    <CarouselItem>...</CarouselItem>
  </CarouselContent>
  <CarouselPrevious />
  <CarouselNext />
</Carousel>

Examples

Default

1
2
3
4
5
{/* px-12 leaves room for the round buttons, which sit outside the slides. */}
<div className="w-full px-12">
  <Carousel aria-label="Featured items" className="mx-auto w-full max-w-80">
    <CarouselContent>
      {Array.from({ length: 5 }).map((_, index) => (
        <CarouselItem key={index}>
          <div className="p-1">
            <Card>
              <CardContent className="flex aspect-square items-center justify-center p-6">
                <span className="text-4xl font-semibold">{index + 1}</span>
              </CardContent>
            </Card>
          </div>
        </CarouselItem>
      ))}
    </CarouselContent>
    <CarouselPrevious />
    <CarouselNext />
  </Carousel>
</div>

Sizes

Set basis on CarouselItem to show more than one slide: two on phones, three on wider screens.

1
2
3
4
5
<div className="w-full px-12">
  <Carousel aria-label="Related items" opts={{ align: "start" }} className="mx-auto w-full max-w-96">
    <CarouselContent>
      {Array.from({ length: 5 }).map((_, index) => (
        <CarouselItem key={index} className="basis-1/2 md:basis-1/3">
          ...
        </CarouselItem>
      ))}
    </CarouselContent>
    <CarouselPrevious />
    <CarouselNext />
  </Carousel>
</div>

Vertical

With orientation="vertical" the buttons move above and below, and the up and down arrows move the slides.

1
2
3
4
5
<Carousel aria-label="Updates" opts={{ align: "start" }} orientation="vertical" className="w-full max-w-80">
  <CarouselContent className="h-56">
    {Array.from({ length: 5 }).map((_, index) => (
      <CarouselItem key={index} className="basis-1/2">
        <div className="p-1">
          <Card className="h-22 py-0">
            <CardContent className="flex h-full items-center justify-center p-0">
              <span className="text-3xl font-semibold">{index + 1}</span>
            </CardContent>
          </Card>
        </div>
      </CarouselItem>
    ))}
  </CarouselContent>
  <CarouselPrevious />
  <CarouselNext />
</Carousel>

Accessibility

  • The carousel is a region with aria-roledescription="carousel"; give it an aria-label. Each slide is a group named "1 of 5" (WCAG 1.3.1).
  • With focus inside, the arrow keys move the slides (WCAG 2.1.1).
  • Previous and Next have hidden text labels ("Previous slide", "Next slide") and are disabled, not hidden, at the ends. Translate everything with the labels prop.
  • It never advances on its own. If you add autoplay, add a visible pause button too (WCAG 2.2.2).