v1.0.3 — Zero Dependencies

Product image sliders,
beautifully simple.

Drag, swipe, hover-preview — a tiny, zero-dependency slider built for e-commerce product cards. Works with vanilla JS, React, Vue, and Shopify.

$ npm install product-card-slider

~4 KB

Gzipped size

0

Dependencies

12+

Config options

MIT

Licensed

Everything you need, nothing you don't.

Built to be tiny, fast, and accessible out of the box — no heavy frameworks or CSS required.

Drag & Swipe

Native-feeling drag and swipe with momentum physics. Touch and mouse supported with configurable thresholds.

Hover Preview

Shopify-style horizontal zone preview. Move the cursor across the image to browse all angles instantly.

Autoplay + Loop

Configurable autoplay on hover with adjustable interval. Optional infinite loop wraps seamlessly.

Lazy Loading

IntersectionObserver-powered lazy loading. Off-screen images stay unloaded until the card enters the viewport.

Accessible

ARIA roles, keyboard navigation, and focus management built in. Screen reader friendly out of the box.

Framework Agnostic

Vanilla JS core. Works with React, Vue, Svelte, or plain HTML. ESM and UMD bundles included.

See it in action

Interactive product cards powered by ProductCardSlider. Try dragging, hovering, and clicking arrows.

Up and running in seconds

Just add your images, import the library, and initialize. That's it.

index.html
<!-- Your product card markup -->
<div class="product-slider">
  <img src="shoe-1.jpg" alt="Front">
  <img src="shoe-2.jpg" alt="Side">
  <img src="shoe-3.jpg" alt="Back">
</div>
app.js
import ProductCardSlider from 'product-card-slider';

// Single instance
new ProductCardSlider('.product-slider', {
  showDots: true,
  showArrows: true,
  lazyLoad: true,
});

// Or init all at once
ProductCardSlider.initAll('.product-slider');
CDN (no build step)
<script src="https://unpkg.com/product-card-slider">
</script>

<script>
  ProductCardSlider.initAll('.slider', {
    hoverPreview: true,
  });
</script>
React
import { useRef, useEffect } from 'react';
import ProductCardSlider from 'product-card-slider';

function Card({ images }) {
  const ref = useRef();
  useEffect(() => {
    const s = new ProductCardSlider(ref.current);
    return () => s.destroy();
  }, []);

  return (
    <div ref={ref}>
      {images.map(src =>
        <img src={src} key={src} />
      )}
    </div>
  );
}

Configuration options

Every option has a sensible default. Pass only what you need.

Option Type Default Description
autoplaybooleanfalseAuto-advance slides on hover
intervalnumber3000Autoplay interval in ms
showDotsbooleantrueShow dot navigation indicators
showArrowsbooleantrueShow prev/next arrow buttons
loopbooleanfalseInfinite loop wrapping
swipeThresholdnumber50Minimum px to register a swipe
lazyLoadbooleantrueLazy-load off-screen images
hoverPreviewbooleanfalseShopify-style horizontal zone preview
momentumbooleantrueFast flick advances below threshold
injectCSSbooleantrueAuto-inject required styles
prevArrowstring | ElementnullCustom prev arrow HTML or element
nextArrowstring | ElementnullCustom next arrow HTML or element

Ready to ship better product cards?

Install in one command. No config files, no CSS imports, no build step required.