Convert Figma logo to code with AI

dohooo logoreact-native-reanimated-carousel

🎠 React Native swiper/carousel component, fully implemented using reanimated v2, support to iOS/Android/Web. (Swiper/Carousel)

2,702
314
2,702
198

Top Related Projects

Swiper/carousel component for React Native featuring previews, multiple layouts, parallax images, performant handling of huge numbers of items, and more. Compatible with Android & iOS.

The best Swiper component for React Native.

React Native wrapper for the Android ViewPager and iOS UIPageViewController.

UI Components Library for React Native

Quick Overview

React Native Reanimated Carousel is a high-performance, customizable carousel component for React Native applications. It leverages the power of React Native Reanimated 2 to provide smooth animations and gestures, making it ideal for creating fluid and interactive carousel experiences in mobile apps.

Pros

  • High performance with smooth animations using Reanimated 2
  • Highly customizable with various layout options and animation styles
  • Supports both horizontal and vertical orientations
  • Includes built-in pagination and autoplay features

Cons

  • Requires React Native Reanimated 2 as a dependency, which may increase app bundle size
  • Learning curve for developers unfamiliar with Reanimated 2
  • Limited documentation for advanced customization scenarios
  • May require additional setup for certain React Native environments

Code Examples

  1. Basic usage with default settings:
import Carousel from 'react-native-reanimated-carousel';

function MyCarousel() {
  const width = Dimensions.get('window').width;
  return (
    <Carousel
      width={width}
      data={[...new Array(6).keys()]}
      renderItem={({ index }) => (
        <View style={{ flex: 1, justifyContent: 'center' }}>
          <Text style={{ textAlign: 'center', fontSize: 30 }}>{index}</Text>
        </View>
      )}
    />
  );
}
  1. Customized carousel with autoplay and pagination:
<Carousel
  width={width}
  height={300}
  data={data}
  renderItem={renderItem}
  autoPlay={true}
  autoPlayInterval={3000}
  loop
  pagingEnabled
  snapEnabled
  mode="parallax"
  modeConfig={{
    parallaxScrollingScale: 0.9,
    parallaxScrollingOffset: 50,
  }}
  customAnimation={animationStyle}
/>
  1. Vertical carousel with custom animation:
<Carousel
  vertical
  width={width}
  height={height}
  data={data}
  renderItem={renderItem}
  customAnimation={verticalAnimation}
  onSnapToItem={(index) => console.log('Current index:', index)}
/>

Getting Started

  1. Install the package:

    npm install react-native-reanimated-carousel
    
  2. Install and configure React Native Reanimated 2 if not already set up.

  3. Import and use the Carousel component in your React Native app:

    import Carousel from 'react-native-reanimated-carousel';
    
    function App() {
      const width = Dimensions.get('window').width;
      return (
        <Carousel
          width={width}
          data={[1, 2, 3, 4, 5]}
          renderItem={({ item }) => (
            <View style={{ flex: 1, justifyContent: 'center' }}>
              <Text>{item}</Text>
            </View>
          )}
        />
      );
    }
    
  4. Customize the carousel props as needed for your specific use case.

Competitor Comparisons

Swiper/carousel component for React Native featuring previews, multiple layouts, parallax images, performant handling of huge numbers of items, and more. Compatible with Android & iOS.

Pros of react-native-snap-carousel

  • More established and widely used, with a larger community and more resources available
  • Offers a wider range of customization options and features out of the box
  • Better documentation and examples for various use cases

Cons of react-native-snap-carousel

  • Less performant compared to react-native-reanimated-carousel, especially for complex animations
  • Not actively maintained, with the last update being over 2 years ago
  • Relies on older animation libraries, which may lead to compatibility issues with newer React Native versions

Code Comparison

react-native-snap-carousel:

<Carousel
  data={items}
  renderItem={renderItem}
  sliderWidth={sliderWidth}
  itemWidth={itemWidth}
  loop={true}
  autoplay={true}
/>

react-native-reanimated-carousel:

<Carousel
  loop
  width={width}
  height={height}
  autoPlay={true}
  data={items}
  renderItem={renderItem}
/>

Both libraries offer similar basic functionality, but react-native-reanimated-carousel has a more streamlined API and better performance due to its use of the Reanimated library. While react-native-snap-carousel provides more built-in features, react-native-reanimated-carousel offers greater flexibility for custom animations and is actively maintained, making it a better choice for newer projects or those requiring high performance.

The best Swiper component for React Native.

Pros of react-native-swiper

  • Simpler implementation for basic swiper functionality
  • Lightweight and less resource-intensive
  • Wider compatibility with older React Native versions

Cons of react-native-swiper

  • Limited animation options compared to react-native-reanimated-carousel
  • Less customizable in terms of advanced features and transitions
  • Not optimized for performance with large datasets or complex layouts

Code Comparison

react-native-swiper:

<Swiper>
  <View style={styles.slide1}><Text>Slide 1</Text></View>
  <View style={styles.slide2}><Text>Slide 2</Text></View>
  <View style={styles.slide3}><Text>Slide 3</Text></View>
</Swiper>

react-native-reanimated-carousel:

<Carousel
  loop
  width={300}
  height={150}
  data={[...new Array(6).keys()]}
  renderItem={({ index }) => (
    <View style={styles.slide}><Text>Slide {index}</Text></View>
  )}
/>

The react-native-reanimated-carousel offers more advanced features and smoother animations, leveraging the power of react-native-reanimated. It provides better performance for complex layouts and large datasets. However, it has a steeper learning curve and requires more setup.

react-native-swiper is easier to implement for basic swiping functionality and is more lightweight. It's suitable for simpler projects or those with limited resources. However, it lacks advanced animation options and may not perform as well with complex layouts or large datasets.

Choose based on your project's complexity, performance requirements, and desired customization level.

React Native wrapper for the Android ViewPager and iOS UIPageViewController.

Pros of react-native-pager-view

  • Native implementation for better performance and smoother animations
  • Supports both horizontal and vertical paging
  • Integrates well with other React Native components and libraries

Cons of react-native-pager-view

  • Limited built-in animation options compared to react-native-reanimated-carousel
  • Requires more manual configuration for advanced carousel features
  • Less customizable out-of-the-box for complex layouts

Code Comparison

react-native-pager-view:

import PagerView from 'react-native-pager-view';

<PagerView style={styles.pagerView} initialPage={0}>
  <View key="1"><Text>First page</Text></View>
  <View key="2"><Text>Second page</Text></View>
</PagerView>

react-native-reanimated-carousel:

import Carousel from 'react-native-reanimated-carousel';

<Carousel
  width={300}
  height={200}
  data={[1, 2, 3]}
  renderItem={({ item }) => <View><Text>{item}</Text></View>}
/>

The code comparison shows that react-native-pager-view requires manual rendering of each page, while react-native-reanimated-carousel uses a data-driven approach with a renderItem function. react-native-reanimated-carousel also provides built-in width and height props for easier sizing.

UI Components Library for React Native

Pros of react-native-ui-lib

  • Comprehensive UI component library with a wide range of pre-built elements
  • Highly customizable and themeable components
  • Extensive documentation and examples for easy implementation

Cons of react-native-ui-lib

  • Larger package size due to the extensive component library
  • Steeper learning curve for developers new to the library
  • May require more setup and configuration compared to simpler libraries

Code Comparison

react-native-ui-lib:

import { View, Text, Button } from 'react-native-ui-lib';

const MyComponent = () => (
  <View>
    <Text>Hello, World!</Text>
    <Button label="Click me" onPress={() => {}} />
  </View>
);

react-native-reanimated-carousel:

import Carousel from 'react-native-reanimated-carousel';

const MyCarousel = () => (
  <Carousel
    data={[1, 2, 3, 4]}
    renderItem={({ item }) => <View>{item}</View>}
  />
);

While react-native-ui-lib offers a comprehensive set of UI components, react-native-reanimated-carousel focuses specifically on providing a high-performance carousel component. The choice between the two depends on the project's specific needs, with react-native-ui-lib being more suitable for projects requiring a full UI toolkit, and react-native-reanimated-carousel being ideal for those needing a specialized carousel implementation.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

react-native-reanimated-carousel

Hacktober Badge platforms npm npm npm github issues github closed issues discord chat

The best carousel component in React Native community. ⚡️

  • It completely solved this problem for react-native-snap-carousel
  • Fully implemented using Reanimated 2&3
  • Demo

Getting Started

Check out the documentation website.

Examples

Click on the image to see the code snippets [Try it] 🍺

normal-horizontalnormal-verticalparallax-horizontal
parallax-verticalstack-horizontal-leftstack-horizontal-right
stack-vertical-leftstack-vertical-rightstack-horizontal-right
left-alignright-align

You can make cool animations with custom animation API [Details]

advanced-parallaxpause-advanced-parallaxscale-fade-in-out
rotate-scale-fade-in-outrotate-in-outanim-tab-bar
marqueemultiplecircular
foldtearpress-swipe
cube-3dblur-parallaxcurve
parallax-layersstack-cardsflow
blur-rotate

Sponsors

License

MIT

NPM DownloadsLast 30 Days