Apple Carousel

An infinite Svelte carousel with autoplay, progress dots, captions, and tab controls.

motion-svruned

Installation

pnpm dlx shadcn-svelte@latest add http://sveltekit-prerender/r/apple-carousel.json

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.

Examples

Captions

Overlay responsive captions and actions on each carousel image.

Props

AppleCarouselRoot

Root provider that owns selection, playback, and carousel timing.

NameTypeDefaultDescription
childrenSnippetrequiredCarousel content and controls.
durationnumber5000Time each item remains active during autoplay, in milliseconds.
classstringundefinedAdditional classes applied to the root element.
refHTMLDivElement | nullnullBindable reference to the root element.

AppleCarouselContent

Scrollable viewport that renders real items and seamless loop clones.

NameTypeDefaultDescription
itemsreadonly T[]requiredOrdered data rendered as carousel items.
childrenSnippet<[item: T]>requiredRender snippet that returns one AppleCarouselItem for each item.
classstringundefinedAdditional classes applied to the scroll viewport.
refHTMLDivElement | nullnullBindable reference to the scroll viewport.

AppleCarouselItem

Accessible carousel panel with clone and current-item state.

NameTypeDefaultDescription
childrenSnippetrequiredContent rendered inside the carousel panel.
classstringundefinedAdditional classes applied to the panel.
refHTMLLIElement | nullnullBindable reference to the panel element.

AppleCarouselControls

Layout wrapper for the tab list and playback control.

NameTypeDefaultDescription
childrenSnippetrequiredTab list and play button.
size'default' | 'sm''default'Size of the tab list and play button.
classstringundefinedAdditional classes applied to the controls wrapper.
refHTMLDivElement | nullnullBindable reference to the controls wrapper.

AppleCarouselTabList

Accessible tab list linked to the carousel items.

NameTypeDefaultDescription
itemsreadonly T[]requiredOrdered data rendered as carousel tabs.
childrenSnippet<[item: T]>requiredRender snippet that returns one AppleCarouselTab for each item.
classstringundefinedAdditional classes applied to the tab list.
refHTMLDivElement | nullnullBindable reference to the tab list.

AppleCarouselTab

Progress dot and keyboard-accessible item selector.

NameTypeDefaultDescription
childrenSnippetrequiredAccessible label announced for the tab.
onclick(event: MouseEvent) => voidundefinedCalled before the tab selects its item.
classstringundefinedAdditional classes applied to the tab.
refHTMLButtonElement | nullnullBindable reference to the tab button.

AppleCarouselPlayButton

Play/pause control with a reduced-motion-aware morphing icon.

NameTypeDefaultDescription
onclick(event: MouseEvent) => voidundefinedCalled before the carousel toggles playback.
classstringundefinedAdditional classes applied to the play button.
refHTMLButtonElement | nullnullBindable reference to the play button.