npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@atom_design/carousel

v1.0.4

Published

A customizable React Native carousel component with auto-play, dots navigation, progress bar, and loop support.

Readme

@atom_design/carousel

A highly customizable React Native carousel component with auto-play, dots navigation, progress bar, loop support, and full accessibility features. Part of the Atom Design System.

npm version license

Features

  • 🎠 Smooth Scrolling - Native FlatList-based horizontal scrolling
  • 🔄 Auto-play - Configurable automatic slide transitions
  • 🔁 Loop Mode - Infinite scrolling support
  • 📍 Dot Navigation - Customizable pagination dots
  • 📊 Progress Bar - Visual progress indicator
  • 🎨 Fully Customizable - Style every aspect of the carousel
  • Accessible - Full screen reader support
  • 📱 Responsive - Adapts to screen dimensions
  • 🖼️ Custom Rendering - Use renderItem for complete control
  • 💪 TypeScript Support - Full type definitions included

📦 Installation

npm install @atom_design/carousel
# or
yarn add @atom_design/carousel

Peer Dependencies

npm install react react-native prop-types

🚀 Basic Usage

import React from 'react';
import { View } from 'react-native';
import Carousel from '@atom_design/carousel';

const App = () => {
  const slides = [
    { id: 1, background: 'https://picsum.photos/800/400?random=1', content: 'Summer Sale' },
    { id: 2, background: 'https://picsum.photos/800/400?random=2', content: 'New Arrivals' },
    { id: 3, background: 'https://picsum.photos/800/400?random=3', content: 'Best Sellers' },
  ];

  return (
    <View style={{ flex: 1 }}>
      <Carousel
        slides={slides}
        autoPlay
        showDots
        height={200}
      />
    </View>
  );
};

export default App;

🧩 Props

Core Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | slides | SlideItem[] | Required | Array of slide objects to display | | renderSlide | (slide, index, isActive) => ReactNode | undefined | Custom render function for slides | | autoPlay | boolean | true | Enable auto-play functionality | | autoPlayInterval | number | 3000 | Interval between transitions (ms) | | loop | boolean | true | Enable infinite loop scrolling | | showDots | boolean | true | Show navigation dots | | showProgressBar | boolean | true | Show progress bar | | aspectRatio | number | 2.37 | Aspect ratio (width/height) for slides | | height | number | auto | Custom height (overrides aspectRatio) |

Callback Props

| Prop | Type | Description | |------|------|-------------| | onSlideChange | (index) => void | Called when active slide changes | | onSlidePress | (slide, index) => void | Called when a slide is pressed |

Style Props

| Prop | Type | Description | |------|------|-------------| | containerStyle | ViewStyle | Style for the carousel container | | slideStyle | ViewStyle | Style for each slide wrapper | | imageResizeMode | string | Image resize mode: 'cover', 'contain', 'stretch', 'center' |

Dot Customization Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | dotsContainerStyle | ViewStyle | undefined | Style for the dots container | | dotStyle | ViewStyle | undefined | Style for individual dot | | activeDotStyle | ViewStyle | undefined | Style for the active dot | | inactiveColor | string | '#ccc' | Color of inactive dots | | activeColor | string | '#d9232d' | Color of active dot | | dotSize | number | 9 | Size of the dots |

Progress Bar Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | progressBarStyle | ViewStyle | undefined | Style for progress bar | | progressBarBackgroundColor | string | '#f0f0f0' | Progress bar background | | progressBarColor | string | '#d9232d' | Progress bar fill color |

Accessibility Props

| Prop | Type | Description | |------|------|-------------| | testID | string | Test ID for testing frameworks |


📁 SlideItem Type

interface SlideItem {
  id?: string | number;
  background: string;           // Image URL or color (hex/rgb)
  content?: string;             // Text overlay
  textStyle?: object;           // Custom text style
  overlayStyle?: object;        // Custom overlay style
  accessibilityLabel?: string;  // Accessibility label
}

✨ Advanced Examples

With Custom Render Slide

<Carousel
  slides={products}
  renderSlide={(slide, index, isActive) => (
    <View style={styles.slide}>
      <Image source={{ uri: slide.background }} style={styles.image} />
      <View style={styles.overlay}>
        <Text style={styles.title}>{slide.content}</Text>
        <Text style={styles.price}>${slide.price}</Text>
        <TouchableOpacity style={styles.button}>
          <Text>Shop Now</Text>
        </TouchableOpacity>
      </View>
    </View>
  )}
  height={300}
  showDots
/>

With Progress Bar

<Carousel
  slides={banners}
  autoPlay
  autoPlayInterval={5000}
  showProgressBar
  showDots={false}
  progressBarColor="#4CAF50"
/>

Custom Styled Dots

<Carousel
  slides={items}
  showDots
  dotSize={10}
  inactiveColor="#cccccc"
  activeColor="#ff6b6b"
  activeDotStyle={{
    width: 24,
    borderRadius: 5,
  }}
  dotsContainerStyle={{
    bottom: 20,
  }}
/>

🧪 Full Test Screen Example

import React from 'react';
import {
  View,
  Text,
  StyleSheet,
  ScrollView,
  SafeAreaView,
  Dimensions,
} from 'react-native';
import Carousel from '@atom_design/carousel';

const { width: SCREEN_WIDTH } = Dimensions.get('window');

// Image slides - uses image URLs
const imageSlides = [
  { id: 1, background: 'https://picsum.photos/800/400?random=1', content: 'Summer Collection' },
  { id: 2, background: 'https://picsum.photos/800/400?random=2', content: 'New Arrivals' },
  { id: 3, background: 'https://picsum.photos/800/400?random=3', content: 'Flash Sale' },
];

// Color slides - uses hex colors
const colorSlides = [
  { id: 1, background: '#d9232d', content: 'Welcome to Moglix' },
  { id: 2, background: '#2196F3', content: 'Best Deals' },
  { id: 3, background: '#4CAF50', content: 'Shop Now' },
];

// Compact slides
const compactSlides = [
  { id: 1, background: 'https://picsum.photos/800/300?random=4' },
  { id: 2, background: 'https://picsum.photos/800/300?random=5' },
  { id: 3, background: 'https://picsum.photos/800/300?random=6' },
];

const CarouselTestScreen = () => {
  return (
    <SafeAreaView style={styles.container}>
      <ScrollView>
        {/* Header */}
        <Text style={styles.header}>Carousel Test</Text>

        {/* Image Carousel */}
        <View style={styles.section}>
          <Text style={styles.sectionTitle}>Image Carousel</Text>
          <Carousel
            slides={imageSlides}
            autoPlay
            autoPlayInterval={3000}
            showDots
            showProgressBar
            height={200}
            onSlideChange={(index) => console.log('Slide:', index)}
          />
        </View>

        {/* Color Carousel */}
        <View style={styles.section}>
          <Text style={styles.sectionTitle}>Color Carousel</Text>
          <Carousel
            slides={colorSlides}
            autoPlay
            autoPlayInterval={2500}
            showDots
            showProgressBar
            height={180}
            activeColor="#fff"
            inactiveColor="rgba(255,255,255,0.5)"
            progressBarColor="#fff"
          />
        </View>

        {/* Compact Carousel */}
        <View style={styles.section}>
          <Text style={styles.sectionTitle}>Compact Carousel</Text>
          <Carousel
            slides={compactSlides}
            height={120}
            showDots
            dotSize={6}
          />
        </View>
      </ScrollView>
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
  },
  header: {
    fontSize: 24,
    fontWeight: 'bold',
    textAlign: 'center',
    marginVertical: 20,
  },
  section: {
    marginBottom: 24,
    paddingHorizontal: 16,
  },
  sectionTitle: {
    fontSize: 16,
    fontWeight: '600',
    marginBottom: 10,
  },
});

export default CarouselTestScreen;

♿ Accessibility

The Carousel component is fully accessible:

  • Screen Reader Support: Announces slide changes and positions
  • Accessibility Labels: Describes carousel content
  • Accessibility Hints: Provides navigation instructions
<Carousel
  data={banners}
  accessibilityLabel="Product showcase carousel"
  accessibilityHint="Swipe left or right to view more products"
/>

📝 TypeScript

Full TypeScript support included:

import Carousel from '@atom_design/carousel';

interface SlideItem {
  id: number;
  background: string;
  content?: string;
}

const slides: SlideItem[] = [
  { id: 1, background: 'https://example.com/img.jpg', content: 'Banner 1' },
  { id: 2, background: '#d9232d', content: 'Color Slide' },
];

const MyCarousel: React.FC = () => (
  <Carousel
    slides={slides}
    autoPlay
    showDots
    onSlideChange={(index: number) => {
      console.log('Current slide:', index);
    }}
  />
);

👤 Author

Atom Design Team


📄 License

MIT © Atom Design