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

fill-slider-animation

v1.0.0

Published

Clip-path fill-overlay slider animation for React. Perfect for landing pages, hero sections, and project showcases.

Readme

fill-slider-animation

A reusable clip-path fill-overlay slider for React. The next slide animates over the current one (right-to-left or left-to-right) instead of fading or swapping. Ideal for landing pages, hero sections, and project showcases.

Installation

npm install fill-slider-animation
# or
yarn add fill-slider-animation
# or (from local packages folder)
npm install ../packages/fill-slider-animation

Quick Start

import { useFillSlider, FillSlider } from "fill-slider-animation";
import "fill-slider-animation/styles.css";

const slides = [
  { src: "/img1.jpg", title: "Slide 1" },
  { src: "/img2.jpg", title: "Slide 2" },
];

// Option 1: Use the hook (full control)
function MySlider() {
  const { activeIndex, overlay, goNext, goPrev, displayIndex } = useFillSlider({
    itemCount: slides.length,
    duration: 2400, // ms, must match CSS
  });

  return (
    <div className="relative w-full h-screen">
      {/* Base layer */}
      <div className="absolute inset-0">
        <img src={slides[activeIndex].src} alt="" className="w-full h-full object-cover" />
      </div>

      {/* Overlay (during transition) */}
      {overlay && (
        <div className={`fill-slider-overlay fill-slider-overlay--${overlay.direction}`}>
          <img src={slides[overlay.index].src} alt="" className="w-full h-full object-cover" />
        </div>
      )}

      <button onClick={goPrev}>Prev</button>
      <button onClick={goNext}>Next</button>
      <h2>{slides[displayIndex].title}</h2>
    </div>
  );
}

// Option 2: Use the component (render props)
function MySliderWithComponent() {
  return (
    <FillSlider
      items={slides}
      renderSlide={(item) => (
        <img src={item.src} alt={item.title} className="w-full h-full object-cover" />
      )}
      duration={2400}
    >
      {({ layers, goNext, goPrev, displayItem }) => (
        <div className="relative w-full h-screen">
          <div className="absolute inset-0">{layers}</div>
          <button onClick={goPrev}>Prev</button>
          <button onClick={goNext}>Next</button>
          <h2>{displayItem.title}</h2>
        </div>
      )}
    </FillSlider>
  );
}

API

useFillSlider(options)

| Option | Type | Default | Description | |--------------|----------|---------|--------------------------------------| | itemCount | number | — | Total number of slides | | duration | number | 2400 | Animation duration in ms | | loop | boolean | true | Loop at end (prev/next wrap around) |

Returns:
{ activeIndex, overlay, displayIndex, goNext, goPrev, isTransitioning }

  • activeIndex — Current slide index
  • overlay{ index, direction } or null during transition
  • displayIndex — Use for title/description (overlay during transition, else active)
  • goNext / goPrev — Navigation handlers
  • isTransitioningtrue while animation runs

FillSlider component

| Prop | Type | Default | Description | |-----------------|----------|---------|-------------------------------------------| | items | T[] | — | Array of slide data | | renderSlide | function | — | (item, index, { isOverlay }) => ReactNode| | duration | number | 2400 | Animation duration in ms | | loop | boolean | true | Loop at end | | layerClassName| string | — | Class for base/overlay inner wrappers | | renderThumb | function | — | Optional thumbnail (item, index) => ReactNode | | thumbTrackClassName | string | — | Class for thumb track | | children | function | — | Render prop ({ layers, thumb, goNext, goPrev, displayItem, ... }) => ReactNode |

CSS classes

  • fill-slider-overlay — Overlay container (position absolute, inset 0)
  • fill-slider-overlay--next — Direction: right → left
  • fill-slider-overlay--prev — Direction: left → right
  • fill-slider-thumb-track — Thumbnail container
  • fill-slider-thumb-base — Thumb base layer
  • fill-slider-thumb-overlay / --next / --prev — Thumb overlay

CSS variables

:root {
  --fill-slider-duration: 2.4s;
  --fill-slider-easing: cubic-bezier(0.34, 1.35, 0.64, 1);
}

Override on .fill-slider-overlay or a parent to change animation timing.

How it works

The overlay is clipped with clip-path: inset(). The visible region is animated:

  • Next: inset(0 0 0 100%)inset(0 0 0 0) — reveal from right
  • Prev: inset(0 100% 0 0)inset(0 0 0 0) — reveal from left

No transform-based sliding; pure clip-path for smooth, GPU-friendly animation.

Using in other projects

Option A: Copy the package

Copy the packages/fill-slider-animation folder into your project (e.g. lib/fill-slider-animation), then:

npm install
# In your package.json:
"fill-slider-animation": "file:./lib/fill-slider-animation"

Option B: Publish to npm

cd packages/fill-slider-animation
npm login                    # If not logged in
npm run build                # Ensure dist is up to date
npm publish                 # Unscoped
# Or for scoped (if name is taken): npm publish --access public

# Then in any project:
npm install fill-slider-animation

Option C: Monorepo / workspace

Add to your root package.json:

{
  "workspaces": ["packages/*"],
  "dependencies": {
    "fill-slider-animation": "workspace:*"
  }
}

License

MIT