Skip to content

Carousel

A swipeable carousel component with gesture support, auto-play, and customizable pagination indicators.

import { Carousel } from '@truongdq01/ui';
import { Carousel } from '@truongdq01/ui';
const slides = [
{ id: '1', image: require('./slide1.png'), title: 'Slide One' },
{ id: '2', image: require('./slide2.png'), title: 'Slide Two' },
{ id: '3', image: require('./slide3.png'), title: 'Slide Three' },
];
export function MyCarousel() {
return (
<Carousel
data={slides}
renderItem={({ item }) => (
<Image source={item.image} style={{ width: '100%', height: 200 }} />
)}
autoPlay
autoPlayInterval={3000}
showPagination
/>
);
}
PropTypeDefaultDescription
dataT[]requiredArray of slide data
renderItem(info: { item: T, index: number }) => ReactNoderequiredRender function for each slide
autoPlaybooleanfalseAuto-advance slides
autoPlayIntervalnumber3000Interval in ms between slides
showPaginationbooleantrueShow pagination dots
loopbooleantrueLoop back to first slide
onIndexChange(index: number) => voidCalled when active index changes
paginationStyle"dots" | "bar" | "numbers""dots"Pagination indicator style
  • Built with react-native-gesture-handler for native swipe gestures
  • Runs on UI thread for 60fps animations