Carousel

Carousels show a collection of items that can be scrolled on and off the screen.

Use Carousel with CarouselItem children to create a horizontally scrollable showcase.

Behavior and callbacks

  • gap: spacing between items.
  • scrollSensitivity: adjust scroll/drag responsiveness.
  • defaultIndex: initial centered index for uncontrolled usage.
  • onIndexChange: called with the accepted centered-index transition.

Svelte uses bind:index for controlled selection and keeps CarouselItem content in the component’s children snippet.

With navigation buttons

onMetricsChange/metricsChange reports the currently visible item count, so external controls can step by a sensible amount and stay in sync with the carousel’s own scroll position. Svelte receives the same metrics object through onMetricsChange.

Visible ≈ 0.00 (full 0), step: 1