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

@arraypress/before-after-astro

v1.0.0

Published

Astro image-comparison slider — draggable handle, keyboard accessible, theme-token CSS.

Readme

@arraypress/before-after-astro

Astro image-comparison slider. Two stacked images, top one clipped by a draggable handle. Mouse / touch / pen / keyboard.

Common uses: design before/after, photo retouch, dark/light mode preview, UI redesigns, plugin chain audio screenshots.

Install

npm install @arraypress/before-after-astro

Use

---
import { BeforeAfter } from '@arraypress/before-after-astro';
import '@arraypress/before-after-astro/style.css';
---
<BeforeAfter
  before="/img/raw.jpg"
  after="/img/processed.jpg"
  beforeLabel="Raw"
  afterLabel="Processed"
  aspectRatio="16 / 9"
  startAt={50}
/>

Props

| Prop | Default | Description | |---------------|----------------------|-------------------------------------------------------------------------| | before | required | URL of the left image. | | after | required | URL of the right (clipped) image. | | beforeAlt | '' | Alt text for the before image. | | afterAlt | '' | Alt text for the after image. | | beforeLabel | — | Optional pill label on the before side. | | afterLabel | — | Optional pill label on the after side. | | aspectRatio | '16 / 9' | CSS aspect-ratio value. | | startAt | 50 | Starting divider position (0–100). | | handleLabel | 'Drag to compare' | aria-label for the handle. | | class | — | Extra classes on the outer wrapper. |

Keyboard

Focus the handle (Tab) and use ← / → to step the divider in 5% increments. The role="slider" + aria-valuenow give screen readers a live read-out of the current position.

Styling

The canonical stylesheet exposes everything via CSS custom properties:

:root {
  --ba-radius: 14px;
  --ba-bg: #141414;
  --ba-border: rgba(255, 255, 255, 0.08);
  --ba-handle-color: rgba(255, 255, 255, 0.85);
  --ba-handle-grip-bg: #f5f5f5;
  --ba-handle-grip-fg: #141414;
  --ba-focus-ring: #ffe26e;
}

Override any of these to rebrand. Or write your own stylesheet from scratch keyed on .before-after, .before-after-viewer, .before-after-img--before/--after, .before-after-label, .before-after-handle, .before-after-handle-grip.

Programmatic access

import {
  initBeforeAfterSlider,
  initAllBeforeAfter,
  calculateClipPercent,
} from '@arraypress/before-after-astro';

/* Bind a specific viewer (the component does this automatically). */
const el = document.querySelector<HTMLElement>('[data-before-after]');
if (el) initBeforeAfterSlider(el);

/* Or every viewer on the page in one call. */
initAllBeforeAfter();

/* Pure-math helper — handy for custom drag interactions. */
const pct = calculateClipPercent(clientX, element.getBoundingClientRect());

Both initBeforeAfterSlider and initAllBeforeAfter are idempotent — calling twice on the same element is a no-op (guarded via dataset.baInit). Safe to re-fire on astro:after-swap.

License

MIT