Apple Carousel
Infinite autoplay carousel with progress dots, inspired by Apple’s website.
Features
- Loops endlessly, with neighboring cards peeking in.
- Autoplays with a progress dot, and pauses on interaction or when off screen.
- Swipe, scroll, click a dot, or use arrow keys, even mid-slide.
- Respects reduced motion: no autoplay until Play is pressed, and cards jump instead of sliding.
Installation
pnpm dlx shadcn@latest add @ncdai/apple-carousel
Usage
import {
AppleCarouselContent,
AppleCarouselControls,
AppleCarouselItem,
AppleCarouselPlayButton,
AppleCarouselRoot,
AppleCarouselTab,
AppleCarouselTabList,
} from "@/components/apple-carousel"<AppleCarouselRoot>
<AppleCarouselContent>
<AppleCarouselItem />
</AppleCarouselContent>
<AppleCarouselControls>
<AppleCarouselTabList aria-label="Featured">
<AppleCarouselTab />
</AppleCarouselTabList>
<AppleCarouselPlayButton />
</AppleCarouselControls>
</AppleCarouselRoot>Items are empty cards for any content. Render one AppleCarouselTab per item, in the same order, with a label for screen readers.
Composition
Use the following composition to build an AppleCarousel
AppleCarouselRoot
├── AppleCarouselContent
│ └── AppleCarouselItem
└── AppleCarouselControls
├── AppleCarouselTabList
│ └── AppleCarouselTab
└── AppleCarouselPlayButtonAPI reference
AppleCarouselRoot
Prop
Type
useAppleCarouselItem
Reads the state of the enclosing AppleCarouselItem.
Prop
Type
Item content also renders in up to two clones, so ids repeat and effects run
per copy. Check isClone before playing media, fetching data, or tracking
impressions.
Data attributes
Style content by state, for example with in-data-current:opacity-100.
| Attribute | Element | Present when |
|---|---|---|
data-current | AppleCarouselItem, AppleCarouselTab | The item or tab is shown. |
data-clone | AppleCarouselItem | The item is a clone. |
data-index | AppleCarouselItem | Always. |
data-playing | AppleCarouselRoot | Autoplay is running. |
Examples
Caption
A caption and Button over each photo. data-current fades captions on peeking cards, and dark keeps text light in both themes.






