Carousel
A scroll-snap carousel with spring slide effects, gliding dots, keyboard navigation and pointer drag.
Customize
Installation
npx shadcn@latest add @kinetic/carouselUsage
Put slides in CarouselContent as CarouselItems and add the controls you need.
import {
Carousel,
CarouselContent,
CarouselDots,
CarouselItem,
CarouselNext,
CarouselPrevious,
} from "@/components/kinetic/ui/carousel";
export function Gallery() {
return (
<Carousel className="mx-12 max-w-md">
<CarouselContent>
{[1, 2, 3].map((n) => (
<CarouselItem key={n} className="basis-3/4">
<div className="flex aspect-video items-center justify-center rounded-lg border">{n}</div>
</CarouselItem>
))}
</CarouselContent>
<CarouselPrevious />
<CarouselNext />
<CarouselDots />
</Carousel>
);
}Effects
Set effect to focus (scale and fade toward the center slide), depth (a layered shift), or none for plain scroll snapping.
<Carousel effect="depth">...</Carousel>Orientation
Set orientation="vertical" to scroll on the vertical axis. Arrow keys and controls follow the axis.
<Carousel orientation="vertical" className="h-72">...</Carousel>Options
opts takes align (start, center, end), startIndex and loop. Control slide width with basis-* classes on CarouselItem.
<Carousel opts={{ align: "start", loop: true }}>...</Carousel>API
setApi hands you an object with scrollPrev, scrollNext, scrollTo, selectedScrollSnap, on and off. Inside the carousel, useCarousel() reads the same state.
const [api, setApi] = useState<CarouselApi | null>(null);
<Carousel setApi={setApi}>...</Carousel>Motion preferences
Use speed to scale the slide springs, arrow nudges and dot transitions. Reduced motion keeps scroll snapping and drops the slide effects.
API Reference
Carousel
Zero-dependency native scroll-snap carousel region with Euler spring focus/depth effects, keyboard navigation, and live slide announcements.
| Prop | Type | Default | Description |
|---|---|---|---|
orientation | "horizontal" | "vertical" | "horizontal" | Scroll axis for slides, arrow keys, and navigation controls. |
effect | "focus" | "depth" | "none" | "focus" | Spring scroll-linked slide treatment: subtle scale/opacity focus attenuation, depth shift ('parallax' alias also accepted), or plain scroll snap. |
opts | CarouselOptions | { align: "center", loop: false } | Scroll options including align ('start' | 'center' | 'end'), loop, startIndex, and axis. |
loop | boolean | false | Wraps previous/next and dot keyboard navigation past the first or last slide. |
speed | number | 1 | Speed multiplier for slide spring effects, nav chevron nudges, dot transitions, and scroll settle detection (clamped 0.25-4). |
setApi | (api: CarouselApi) => void | - | Callback providing the imperative CarouselApi (scrollPrev, scrollNext, scrollTo, selectedScrollSnap, on, off). |
CarouselContent / CarouselItem / CarouselPrevious / CarouselNext / CarouselDots / useCarousel
Scroll viewport, slide item slot, Button-backed navigation arrows with spring nudges and boundary focus recovery, velocity-stretching indicator dots, and context hook.
| Prop | Type | Default | Description |
|---|---|---|---|
variant / size (CarouselPrevious / CarouselNext) | Button["variant"] / Button["size"] | variant="outline", size="icon" | Button appearance and sizing forwarded to previous/next arrow controls. |
tabIndex (CarouselContent) | number | 0 | Keeps the scroll container keyboard-reachable for scrolling and focus fallback. |
aria-label (CarouselDots) | string | "Choose a slide" | Accessible group label for the spring-animated slide marker dots. |