Carousel
NavigationLets readers move through a horizontal collection of slides using scrolling and navigation controls.
Try it
Add to your project
npx shadcn@latest add https://luv-jeri.github.io/cojeev-ui/r/carousel.jsonThe command includes the component’s shared dependencies. Your project keeps editable source files.
Include the complete example
This example also composes badge, card, typography. Install its parts together:
npx shadcn@latest add https://luv-jeri.github.io/cojeev-ui/r/carousel.json https://luv-jeri.github.io/cojeev-ui/r/badge.json https://luv-jeri.github.io/cojeev-ui/r/card.json https://luv-jeri.github.io/cojeev-ui/r/typography.jsonUsing carousel
Place CarouselItem elements inside CarouselContent and add Previous, Next, or Dot controls as needed.
Use onIndexChange to synchronize a slide count or related content with the current position.
API
Compose the exported parts below. The prop types are read from the React source during the registry build.
Native element or underlying primitive props are inherited where declared, including accessible labels, event handlers and refs.
CarouselProps
| Prop | Type | Required |
|---|---|---|
onIndexChange | (index: number) => void | No |
CarouselContentProps
Accepts the native or primitive props declared by its exported TypeScript type.
CarouselItemProps
| Prop | Type | Required |
|---|---|---|
asChild | boolean | No |
CarouselNavigationProps
Accepts the native or primitive props declared by its exported TypeScript type.
CarouselPreviousProps
Accepts the native or primitive props declared by its exported TypeScript type.
CarouselNextProps
Accepts the native or primitive props declared by its exported TypeScript type.
CarouselDotsProps
Accepts the native or primitive props declared by its exported TypeScript type.
CarouselDotProps
| Prop | Type | Required |
|---|---|---|
index | number | Yes |
CarouselDeckProps
Accepts the native or primitive props declared by its exported TypeScript type.
Accessibility
Give the carousel region an accessible name and provide descriptive slide content.
Retain the labeled navigation buttons and the content keyboard handler when composing custom controls.
States and appearance
For conditional content, keep a MotionPresence boundary around keyed MotionSurface children. The shared entrance and exit states work with native primitives and respect your motion preference.
Try pointer and keyboard interaction, and switch the appearance control in the navigation to compare light and dark mode. Motion respects reduced motion preferences.