Installation
$ pnpm dlx shadcn@latest add @synccn/carouselFirst time in this project? Connect synccn with one command.
Usage
import { Carousel } from "@/components/ui/carousel";<Carousel perView={3} autoplay={4000}>…</Carousel>API reference
Generated from the component's TypeScript types, so it always matches the code.
Carousel
Scroll-snap carousel: swipe, drag-free on touch, arrow buttons, dots, keyboard arrows and optional autoplay (paused on hover and focus, off for reduced motion).
PropTypeDescription
- perView
numberDefault
1Slides visible at once.
- gap
numberDefault
12Space between slides in pixels.
- autoplay
numberDefault
0Milliseconds between automatic slides. 0 turns it off.
- loop
booleanDefault
trueWrap from the last slide to the first.
- children
React.ReactNodeContent to render.
- className
stringExtra classes for the root element.
Dependencies
Read from the component's imports when the site builds. The CLI installs all of these for you.
Helpers
- lib/utilscn (merges class names)
npm packages
- clsx for cn()
- tailwind-merge for cn()
- lucide-react for ChevronLeft, ChevronRight
Keyboard
- ←or→Previous or next slide, when the carousel has focus
Accessibility
- Autoplay pauses on hover and focus, and is off for people who prefer reduced motion.
From the source
Read from this component's code when the site builds, so it can't drift.
- ARIA roles: group, region
- ARIA attributes: aria-current, aria-label, aria-roledescription
- Keys handled: ArrowLeft, ArrowRight
- Respects the reduced motion setting
- Shows a visible focus ring for keyboard users
More display
CardSurface with header, content and footer slots.BadgeSmall status label with an optional dot.AvatarImage with initials fallback, presence dot and stacked groups.KbdKeyboard key for shortcuts and hints.SeparatorHorizontal, vertical or labelled divider.AccordionExpanding sections with smooth height animation.