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 🙏

© 2026 – Pkg Stats / Ryan Hefner

universal-headless-carousel

v1.1.1

Published

Headless, cross-platform (React & React Native) carousel engine with CSS Scroll Snap & FlatList physics

Readme

universal-headless-carousel 🎠

CI/CD Publish Pipeline License: MIT

A cross-platform (React & React Native) carousel npm package with ready-to-use drop-in UI components AND headless hooks. Features custom arrows, custom pagination dots, custom card dimensions (cardWidth / cardHeight), CSS Scroll Snap, and native FlatList physics. Zero forced UI, 100% style customization, and production-grade accessibility (A11y).


🎨 Visual Previews

🌐 Web Carousel (CSS Scroll Snap Engine)

Web Carousel Preview

📱 React Native Carousel (FlatList Engine)


📦 Packages

| Package | Version | Description | | :--- | :--- | :--- | | universal-headless-carousel-core | 1.1.1 | Framework-agnostic state machine & math engine | | universal-headless-carousel-web | 1.1.1 | Web engine & <Carousel /> drop-in component | | universal-headless-carousel-native | 1.1.1 | React Native engine & <NativeCarousel /> drop-in component |


🚀 Installation

# npm
npm install universal-headless-carousel

# pnpm
pnpm add universal-headless-carousel

💡 Quick Start

🌐 1. Custom Web Component (<Carousel />)

Pass custom card dimensions (cardWidth, cardHeight), custom arrow icons (prevArrow, nextArrow), or custom pagination dots (customDot):

import React from 'react';
import { Carousel } from 'universal-headless-carousel/web';

export function WebComponentExample() {
  return (
    <Carousel
      cardWidth={320}
      cardHeight={200}
      items={[
        <div key="1" style={{ padding: 20, background: '#3b82f6', color: '#fff', borderRadius: 12 }}>Product Card 1</div>,
        <div key="2" style={{ padding: 20, background: '#10b981', color: '#fff', borderRadius: 12 }}>Product Card 2</div>,
        <div key="3" style={{ padding: 20, background: '#8b5cf6', color: '#fff', borderRadius: 12 }}>Product Card 3</div>
      ]}
      loop
      autoplay={3000}
      showArrows
      prevArrow={<span>◀ Left</span>}
      nextArrow={<span>Right ▶</span>}
      showDots
      customDot={(index, isActive) => (
        <span style={{ color: isActive ? '#3b82f6' : '#cbd5e1', fontSize: 18 }}>
          {isActive ? '●' : '○'}
        </span>
      )}
    />
  );
}

📱 2. Custom React Native Component (<NativeCarousel />)

import React from 'react';
import { View, Text } from 'react-native';
import { NativeCarousel } from 'universal-headless-carousel/native';

export function NativeComponentExample() {
  return (
    <NativeCarousel
      cardWidth={300}
      cardHeight={180}
      items={[
        <View key="1" style={{ height: 180, backgroundColor: '#3b82f6', borderRadius: 12, justifyContent: 'center', alignItems: 'center' }}>
          <Text style={{ color: '#fff', fontSize: 20 }}>Native Slide 1</Text>
        </View>,
        <View key="2" style={{ height: 180, backgroundColor: '#10b981', borderRadius: 12, justifyContent: 'center', alignItems: 'center' }}>
          <Text style={{ color: '#fff', fontSize: 20 }}>Native Slide 2</Text>
        </View>
      ]}
      loop
      showArrows
      prevArrow={<Text style={{ fontSize: 16 }}>◀ Prev</Text>}
      nextArrow={<Text style={{ fontSize: 16 }}>Next ▶</Text>}
      showDots
      customDot={(index, isActive) => (
        <Text style={{ color: isActive ? '#3b82f6' : '#cbd5e1', fontSize: 16, marginHorizontal: 4 }}>
          {isActive ? '★' : '☆'}
        </Text>
      )}
    />
  );
}

🛠 3. Headless Web Hook (useWebCarousel)

For custom layouts or DOM-level control:

import React from 'react';
import { useWebCarousel } from 'universal-headless-carousel/web';

const items = ['Slide 1', 'Slide 2', 'Slide 3'];

export function CustomWebCarousel() {
  const { activeIndex, next, prev, getContainerProps, getItemProps } = useWebCarousel({
    itemsCount: items.length,
    loop: true,
    autoplay: 3000
  });

  return (
    <div>
      <div {...getContainerProps()}>
        {items.map((item, i) => (
          <div key={i} {...getItemProps(i)}>
            {item} (Active: {i === activeIndex ? 'Yes' : 'No'})
          </div>
        ))}
      </div>
      <button onClick={prev}>Prev</button>
      <button onClick={next}>Next</button>
    </div>
  );
}

♿️ Accessibility (A11y)

Both Web and React Native components auto-inject compliant WAI-ARIA Attributes:

  • Container: role="region", aria-roledescription="carousel", aria-label="Carousel".
  • Keyboard Navigation:
    • ArrowLeft: Navigate to previous slide.
    • ArrowRight: Navigate to next slide.
    • Home: Navigate to first slide.
    • End: Navigate to last slide.
  • Auto-Pause on Hover: Pauses autoplay on mouseenter and resumes on mouseleave.
  • Items: role="group", aria-roledescription="slide", aria-label="Slide X of Y", aria-hidden={!isActive}.

🛠 License

Distributed under the MIT License. See LICENSE for details.