CardCarousel
A carousel that centers the active card and scales down the neighboring peek cards for a focused, stack-like presentation. Perfect for testimonials, product highlights, and feature showcases.
Interactive Demo
Navigate with the arrows or drag to swipe between cards.
Wider peek
Push the side cards further out with peekDistance. Try 90 for a more airy layout where the neighbors are almost fully visible.
Tight stack
Smaller peekDistance values (e.g. 35) stack the cards closer together for a more layered, peeking-behind look.
With arrows and dots
Opt-in to prev/next buttons with showArrows and dot indicators below with showDots. Side cards are still clickable and drag-to-swipe still works.
Dots only
Use just showDots for a minimal look — navigate via dots, drag, or by clicking on side cards.
Usage
import { CardCarousel } from "@mantleui/react/motion";import { ArrowLeft, ArrowRight } from "lucide-react";
const slides = testimonials.map((t) => ( <div key={t.name}>{t.quote}</div>));
// Default<CardCarousel slides={slides} defaultValue={0} loop />
// Wider side cards<CardCarousel slides={slides} peekDistance={90} peekOpacity={0.75} />
// Tight stacked look<CardCarousel slides={slides} peekDistance={35} peekScale={0.8} />
// With arrow buttons<CardCarousel slides={slides} showArrows />
// With dot indicators<CardCarousel slides={slides} showDots />
// Both arrows and dots<CardCarousel slides={slides} showArrows showDots />
// Custom icons<CardCarousel slides={slides} showArrows prevIcon={<ArrowLeft size={20} />} nextIcon={<ArrowRight size={20} />}/>Props
| Prop | Type | Default | Description |
|---|---|---|---|
slides | ReactNode[] | — | The slides/cards to render. |
value | number | — | Controlled current slide index. |
defaultValue | number | 0 | Default current slide index (uncontrolled). |
onValueChange | (index: number) => void | — | Called when the current slide changes. |
autoplay | boolean | false | Whether the carousel auto-advances. |
interval | number | 3000 | Autoplay interval in ms. |
loop | boolean | true | Whether to wrap around at edges. |
peekScale | number | 0.85 | Scale factor applied to the previous/next peek cards. |
peekOpacity | number | 0.6 | Opacity applied to the previous/next peek cards. |
peekDistance | number | 60 | Horizontal distance (as percent of slide width) from center where the peek cards are positioned. Higher values push side cards further out. |
showArrows | boolean | false | Whether to show prev/next arrow buttons. |
showDots | boolean | false | Whether to show dot indicators below the cards. |
prevIcon | ReactNode | — | Custom icon for the previous button. Defaults to a chevron-left. |
nextIcon | ReactNode | — | Custom icon for the next button. Defaults to a chevron-right. |
slidesReactNode[]The slides/cards to render.
valuenumberControlled current slide index.
defaultValue0numberDefault current slide index (uncontrolled).
onValueChange(index: number) => voidCalled when the current slide changes.
autoplayfalsebooleanWhether the carousel auto-advances.
interval3000numberAutoplay interval in ms.
looptruebooleanWhether to wrap around at edges.
peekScale0.85numberScale factor applied to the previous/next peek cards.
peekOpacity0.6numberOpacity applied to the previous/next peek cards.
peekDistance60numberHorizontal distance (as percent of slide width) from center where the peek cards are positioned. Higher values push side cards further out.
showArrowsfalsebooleanWhether to show prev/next arrow buttons.
showDotsfalsebooleanWhether to show dot indicators below the cards.
prevIconReactNodeCustom icon for the previous button. Defaults to a chevron-left.
nextIconReactNodeCustom icon for the next button. Defaults to a chevron-right.