Dokumentation (english)
Components: Shadcn UI

Carousel

Understand the design system and contribute to it

Component preview

The live preview for UI components is handled by components/atoms/codedocs/ComponentPreview.tsx. Use it directly inside MDX whenever you want a playground-style embed. Provide componentProps to set default values and propOptions to surface toggle-able props next to the preview.

Preview
1. Product onboarding
Guide teams as they ship new features.
Each card is a standard Card component, so you can render any content inside.
2. Daily standup
Keep track of blockers and celebrate wins.
Each card is a standard Card component, so you can render any content inside.
3. Retro meeting
Catalog insights and next steps.
Each card is a standard Card component, so you can render any content inside.

Prop reference

Auto-generated from the component source

Carousel

  • orientation = "horizontal"
  • opts
  • setApi
  • plugins
  • className
  • children

React.ComponentProps<"div"> & CarouselProps

CarouselContent

  • className

React.ComponentProps<"div">

CarouselItem

  • className

React.ComponentProps<"div">

CarouselNext

  • className
  • variant = "outline"
  • size = "icon"

React.ComponentProps<typeof Button>

CarouselPrevious

  • className
  • variant = "outline"
  • size = "icon"

React.ComponentProps<typeof Button>

Code
// owner: Sona
"use client";

import {
  Carousel,
  CarouselContent,
  CarouselItem,
  CarouselNext,
  CarouselPrevious,
} from "@/components/ui/carousel";
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from "@/components/ui/card";

const slides = [
  {
    title: "Product onboarding",
    description: "Guide teams as they ship new features.",
  },
  {
    title: "Daily standup",
    description: "Keep track of blockers and celebrate wins.",
  },
  {
    title: "Retro meeting",
    description: "Catalog insights and next steps.",
  },
];

export default function CarouselExample() {
  return (
    <Carousel className="w-full max-w-3xl">
      <CarouselContent>
        {slides.map((slide, index) => (
          <CarouselItem key={slide.title}>
            <Card className="h-48">
              <CardHeader>
                <CardTitle>
                  {index + 1}. {slide.title}
                </CardTitle>
                <CardDescription>{slide.description}</CardDescription>
              </CardHeader>
              <CardContent className="text-sm text-muted-foreground">
                Each card is a standard Card component, so you can render any
                content inside.
              </CardContent>
            </Card>
          </CarouselItem>
        ))}
      </CarouselContent>
      <CarouselPrevious />
      <CarouselNext />
    </Carousel>
  );
}

On this page


Command Palette

Search for a command to run...

Schnellzugriffe
STRG + KSuche
STRG + DNachtmodus / Tagmodus
STRG + LSprache ändern

Software-Details
Kompiliert vor 15 Tagen
Release: v4.0.0-production
Buildnummer: master@6fbd7b5
Historie: 13 Items