Skip to content
Logic2BUI

Search docs

Search components and documentation

New
Menu

Carousel

A carousel of slides with previous/next controls and keyboard navigation.

Installation

npx logic2b@next add carousel

Usage

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

<Carousel>
  <CarouselContent>
    <CarouselItem>1</CarouselItem>
    <CarouselItem>2</CarouselItem>
    <CarouselItem>3</CarouselItem>
  </CarouselContent>
  <CarouselPrevious />
  <CarouselNext />
</Carousel>

Built on embla-carousel-react — pass embla options via the opts prop and plugins via plugins, or get the imperative API with setApi.

Usage notes

CarouselPrevious and CarouselNext accept the standard Button props (variant, size) and are automatically disabled at the ends.

Examples

Multiple items

Set the basis of each CarouselItem to show several slides at once.

Vertical

Use orientation="vertical" to scroll slides top to bottom.

Accessibility

  • The root has role="region" with aria-roledescription="carousel", and each slide is a role="group" labelled as a slide.
  • When the carousel is focused, Arrow Left and Arrow Right scroll to the previous/next slide.
  • The previous/next buttons include sr-only labels and become disabled when there is nothing more to scroll to.

Edit the component props and inspect the exact JSX before copying it. The preview loads only when this section enters the viewport.

Generated JSX
<Carousel
  orientation="horizontal"
  className="w-full max-w-xs"
  aria-label="Registry highlights"
>
  <CarouselContent
    className="h-44"
  >
    <CarouselItem>
      <div
        className="flex h-40 items-center justify-center rounded-lg border bg-muted text-3xl font-semibold"
      >1</div>
    </CarouselItem>
    <CarouselItem>
      <div
        className="flex h-40 items-center justify-center rounded-lg border bg-muted text-3xl font-semibold"
      >2</div>
    </CarouselItem>
    <CarouselItem>
      <div
        className="flex h-40 items-center justify-center rounded-lg border bg-muted text-3xl font-semibold"
      >3</div>
    </CarouselItem>
  </CarouselContent>
  <CarouselPrevious />
  <CarouselNext />
</Carousel>

Generated from the public TypeScript exports in src/ui/carousel.tsx.

View JSON
Type
type CarouselApi = UseEmblaCarouselType[1]
Component
Props: React.ComponentProps<"div"> & CarouselProps
PropTypeRequiredDefaultDescription
orientation"horizontal" | "vertical"No"horizontal"—
optsCarouselOptionsNo——
setApi(api: CarouselApi) => voidNo——
pluginsCarouselPluginNo——
Component
Props: React.ComponentProps<"div">
Component
Props: React.ComponentProps<"div">
Component
Props: React.ComponentProps<typeof Button>
PropTypeRequiredDefaultDescription
variantnull | "link" | "default" | "destructive" | "secondary" | "outline" | "ghost"No"outline"—
sizenull | "default" | "sm" | "lg" | "icon"No"icon"—
Component
Props: React.ComponentProps<typeof Button>
PropTypeRequiredDefaultDescription
variantnull | "link" | "default" | "destructive" | "secondary" | "outline" | "ghost"No"outline"—
sizenull | "default" | "sm" | "lg" | "icon"No"icon"—

Machine-readable behavior and consumer responsibilities for carousel.

View JSON
Support
Authored behavior
Pattern
carousel
Embla Carousel
Keyboard interactions for carousel
KeysBehavior
ArrowLeft ArrowRightMove to the previous or next slide.
TabReach the explicit previous/next buttons.

Built-in semantics

  • The root is a labelled carousel region; slides are labelled groups and controls expose names/disabled state.

Consumer responsibilities

  • Give the carousel a contextual aria-label and avoid auto-rotation without a pause control.