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

tw-fade

v0.11.0

Published

Elegant, CSS-driven scroll-edge fade masking for Tailwind CSS v4. Add fade-y, fade-x, fade-start, or fade-end to any scroll container to fade content into its surface at the edges — scroll-gated with zero JavaScript.

Readme

tw-fade

Scroll-aware opacity fades and edge blur for Tailwind CSS v4. Select either effect, or combine them. Each appears while content remains beyond an edge and clears when you reach it.

Using a coding agent? Point your agent at AGENTS.md for stack detection, exact install commands, markup retrofit templates, and automated verification checks.

Opacity fades use a single class. Current (0.11.0+) blur uses a plain div wrapper with GPU-composited backdrop-filter CSS prepared via Vite, the CLI, or renderFadeBlur.

Live demo

| If you want | Path | Setup | | :--- | :--- | :--- | | Opacity fade only | CSS utility on scroller | @import "tw-fade"; or tw-fade/css | | Blur (or fade + blur) with real DOM/framework children | Precompiled blur (0.11.0+) | BLUR-SETUP.md (tw-fade init / tw-fade/vite) or blur-manual.md (tw-fade generate) | | Per-instance dynamic SSR HTML blur | renderFadeBlur (0.11.0+) | BLUR.md (tw-fade/blur, HTML strings only) | | Legacy 0.10.0 CSS-only blur | Stylesheet-only renderer | stylesheet-blur.md |

<div class="fade-y h-64 overflow-y-auto">
  <!-- long content; top and bottom fade as you scroll -->
</div>

Apply opacity-only classes to the scroll container. Opacity fading reveals your existing surface and needs no wrapper. For blur, use the generated setup. The utility reference below also describes the existing stylesheet-only blur path. Its geometry and browser requirements differ from generated blur.

Install

Tailwind v4 source path

Use the source path in a Tailwind v4 app. It generates responsive and state variants, plus bracket values such as fade-size-[2rem].

npm install tw-fade
@import "tailwindcss";
@import "tw-fade";

Prebuilt CSS

Use the prebuilt file with plain HTML, a CDN, or a bundler that imports CSS.

<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/tw-fade.css" />
import "tw-fade/css";

The prebuilt file contains the named, unprefixed utility set. Variants and bracket values require Tailwind's source path. Pin CDN imports to a version to avoid breaking changes.

Usage

Apply opacity-only selectors to the scrolling element. For the precompiled blur setup, put fade-blur-scroll, your blur profile class, and any opacity selector on the inner scrolling child inside fade-blur-frame. For renderFadeBlur and stylesheet-only blur, put selectors and configuration on fade-blur-frame; its first child is the scroller.

| Intent | Classes | | --- | --- | | Vertical opacity fade | fade-y | | Vertical blur | fade-blur-y | | Both effects vertically | fade-y fade-blur-y | | Top blur and bottom opacity fade | fade-blur-top fade-bottom |

<!-- Top and bottom -->
<div class="fade-y h-80 overflow-y-auto">...</div>

<!-- All four edges -->
<div class="fade h-80 overflow-auto">...</div>

<!-- Horizontal rail, direction-aware -->
<div class="fade-x overflow-x-auto">...</div>

<!-- Compose single edges -->
<div class="fade-top fade-end h-80 overflow-auto">...</div>

<!-- Tune the band and travel distance -->
<div class="fade-y fade-size-lg fade-travel-xl h-80 overflow-y-auto">...</div>

Direction Utilities

| Opacity selector | Blur selector | Edges | | --- | --- | --- | | fade | fade-blur | all four edges | | fade-y | fade-blur-y | top + bottom | | fade-top | fade-blur-top | top | | fade-bottom | fade-blur-bottom | bottom | | fade-x | fade-blur-x | horizontal start + horizontal end | | fade-start | fade-blur-start | horizontal start | | fade-end | fade-blur-end | horizontal end |

Selections add together within each effect. fade-top fade-bottom selects both opacity edges. fade-blur-y fade-blur-x selects all blur edges. Neither family changes the other's selection. Strength, geometry, and activation settings do not select edges by themselves.

start and end name horizontal edges and follow the HTML dir attribute. In LTR, start is left and end is right. RTL reverses them. top and bottom stay physical.

Set dir on the plain fade scroller or blur frame, or on an ancestor. A CSS direction: rtl rule does not trigger RTL routing. See the 0.6.x to 0.7+ migration for how physical fade-l/fade-r names map to fade-start/fade-end.

<div dir="rtl" class="fade-start overflow-x-auto">...</div>

Blur

Use a blur selector such as fade-blur-y for blur without opacity fading. Add an opacity selector when you want both effects.

Blur setup

Use the precompiled setup for Vite apps or standalone CLI for Next.js, Astro, SvelteKit, Nuxt, or plain HTML. Both preserve interactive framework and DOM children. In npm + Vite HTML apps, run npx tw-fade init --dry-run then npx tw-fade init --yes to install the build integration. Standard blur is the default; progressive blur is optional with a configurable stop count.

Use the per-instance SSR generator when building trusted HTML strings on the server with custom per-frame size, individual edges, or cornerRadius.

The legacy 0.10.0 stylesheet-only blur reference documents the older fade-blur-md / fade-blur-layer CSS-only renderer.

Size

See edge sizes, travel distance, and clear zones.

Activation Controls

See automatic, always, and disabled effects, including conditional composition.

Scrollbars

See scrollbar shielding and its limits.

Fading The Whole Page

Fade the element that scrolls. For a full-page fade, make <body> the scroll container and keep the surface behind it on <html>.

<html class="h-full overflow-hidden bg-neutral-950">
  <body class="fade-y h-full overflow-y-auto bg-transparent">
    ...
  </body>
</html>
  1. <body> must have a fixed height and overflow-y-auto, otherwise the viewport scrolls instead.
  2. The scroll container should be transparent if you want the mask to reveal the page surface behind it.

Source Path Vs. Prebuilt

| | @import "tw-fade" | tw-fade/css | | --- | --- | --- | | Needs Tailwind v4 | yes | no | | Opacity and blur selectors | yes | yes | | Named blur strengths | yes | yes | | Both activation families, at every scope | yes | yes | | Named size/travel/clear utilities | yes | yes | | fade-scrollbar-safe-* and named fade-scrollbar-width-* | yes | yes | | fade-clear-*-var | yes | yes | | Structural fade-blur-frame | yes, unprefixed | yes, unprefixed | | Structural fade-blur-layer marker | yes, unprefixed | yes, unprefixed | | Responsive and state variants | yes, using the app's theme | no | | Arbitrary values like fade-size-[6rem] | yes | no | | Integer clear values like fade-clear-top-14 | yes | no |

The package build generates the prebuilt file from an explicit safelist. It excludes Tailwind Preflight, core Tailwind utilities, prefixed variants, arbitrary values, and integer fade-clear-* classes. Neither distribution provides arbitrary blur-radius utilities. When classes are built dynamically, include the complete names in Tailwind's scanned source or safelist.

Exports

| Specifier | Resolves to | | --- | --- | | tw-fade | ./src/tw-fade.css | | tw-fade/css | ./dist/tw-fade.css | | tw-fade/dist/tw-fade.css | ./dist/tw-fade.css | | tw-fade/vite | Build plugin for Vite HTML apps | | tw-fade/presets | Validated preset encoding and decoding | | tw-fade/blur | Per-instance HTML/CSS blur generator | | tw-fade/blur.css | Per-instance renderer styles |

tailwindcss >=4.0.0 (for the source path) and vite >=5.0.0 <9 (for tw-fade/vite) are optional peer dependencies. Neither is required for the prebuilt CSS or standalone generation. Node.js 20.19 or newer is supported across both ESM import and CommonJS require() callers.

How It Works

Each effect host uses one shared four-slot animation list for raw scroll progress. Unselected edges have empty slots. Its opacity and blur amounts resolve independently from that progress, their selections, and their activation settings. For a selected edge, auto uses scroll progress, always uses the full amount, and none uses zero. Plain fades use scroll(self y) and scroll(self inline). Frames use named timelines from their first child, isolated by timeline-scope. The :dir() selector routes horizontal start and end.

Opacity uses a 12-layer mask stack: four cosine edge gradients, two full-size repeating-linear-gradient stripe layers that combine into a 4x4 ordered dither, four outer-edge guard layers, and two dormant scrollbar-shield strips. In Chromium, a zero-specificity backdrop-filter: opacity(1) rule keeps masked blending single-pass to prevent 8-bit banding reversals while allowing author backdrop-* utilities to override it (use backdrop-filter-none if a position: fixed descendant must escape a plain Chromium scroller). With a frame, this mask belongs to the scrolling child, while blur overlays render in front of it without masking the frame so the blur can sample the visible background. Missing blur capabilities leave opacity fading available and omit blur.

Raw progress normally stays at 0 when its axis cannot scroll. Forced modes do not change raw progress. Without scroll-driven animations, selected automatic opacity fades use the static full amount; disabled fades stay disabled. Blur remains unavailable even with fade-blur-always.

Effect selections and mode settings are local to each scroller. A nested scroller does not inherit the parent's activation or strength class. Theme tokens can inherit. Ancestor masks, opacity, and filters still affect the composed result; a child effect cannot undo them. An authored mask or ::after on the same host can conflict with the plugin's rendering.

Dynamic content on a stable scrollport

WebKit can retain a stale fade when a mounted scrollport swaps long content for short content. The common case starts with the scroll position at the end. Try these fixes in order:

  1. Upgrade to the latest tw-fade.
  2. Remount or key the scrollport by content identity.
  3. Restart the fade animation after the content swap.
  4. Add fade-none-y or fade-none-x when your app knows that axis cannot overflow. For blur, use fade-blur-none-y or fade-blur-none-x. An element using both effects needs both disable controls for that axis.
<div key={activeTabId} className="fade-y overflow-y-auto">
  {items.map((item) => (
    <ListItem key={item.id} item={item} />
  ))}
</div>

Use this helper after the DOM update when remounting would discard useful element state:

function resetTwFade(el) {
  const previous = el.style.animation
  el.style.animation = 'none'
  void el.offsetHeight
  requestAnimationFrame(() => {
    el.style.animation = previous
  })
}

The helper restarts the shared raw animations for both effects. It does not change selections or activation modes. Browser invalidation can still leave stale state after a content swap; do not treat the helper as a guarantee in affected WebKit builds.

Public Properties

Theme with --fade-size-*, --fade-travel-*, --fade-clear-*, --fade-blur-sm/md/lg, and --fade-scrollbar-width-*. Runtime clear-zone properties such as --fade-clear-top feed the matching -var utilities.

The three author properties are --tw-fade-onset, --tw-fade-scrollbar-width, and --tw-fade-scrollbar-thumb. Treat other --tw-fade-* properties as internal. Raw scroll progress and effective opacity/blur amounts have different meanings; neither is an author-facing activation control.

Accessibility

tw-fade changes appearance without moving content or changing focus order. Masking and blur reduce readability near an edge, so use modest bands and clear zones around controls or critical text. Blur layers pass pointer events through. Empty progressive spans should use aria-hidden="true".

Browser Support

This section describes the stylesheet-only effects. Generated blur uses the requirements and rendering limits in its setup guide.

Opacity requires CSS masking. Its animated path also uses scroll-driven animations, registered numeric custom properties, and :dir() routing. Without scroll timelines, static opacity fallback remains available, including when property registration is unavailable. Activation still applies: selected automatic or forced edges show a static fade, and disabled edges stay clear.

Blur additionally requires backdrop filtering, anchor positioning and scope, and filtered :nth-child(). Syntax support alone does not prove that a browser renders blur correctly. always changes activation; it does not bypass the renderer's capability gate.

| Requested effects | Blur unsupported or anchor ineligible | Scroll timelines unavailable | | --- | --- | --- | | Opacity only | Opacity fade remains | Static opacity fade | | Blur only | Unmodified content | Unmodified content | | Both | Opacity fade remains | Static opacity fade; no blur |

Each effect's disable modes still apply in these fallback paths. A blur-only fallback never introduces an opacity fade. Transform, filter, or paint/layout containment on the scroller can make its anchor ineligible even when all required syntax is supported.

Native Safari 18.6 passes checks for static opacity, disabled effects, and blur-only fallback. It lacks the features required for blur. Safari 26.2 on an iPhone 17 Pro simulator passes single and progressive blur pixel checks through both import paths, plus scroll endpoints, RTL routing, and a tap through the overlay. Physical iPhone rendering remains unverified. WebKit can retain scroll-state residue after content shrinks; this also reproduces in the simulator. See the dynamic-content guidance.

Older WebKit may need -webkit-mask-*. Run the prebuilt CSS through Autoprefixer if you support it.

Migrating

To adopt generated blur in 0.11.0, follow adopting generated blur. Upgrading stylesheet-only blur from 0.9.0 to 0.10.0+ uses containing existing blur scrollers, and earlier upgrades cover the 0.9.0 migration and 0.6.x to 0.7+ rename procedure. Ordinary opacity-only usage keeps its names.

Contributing

Maintainer build and verification commands for developing tw-fade itself (do not run inside consumer applications):

npm test
npm run build
npm run build:demo
npm run verify
npm run verify:generator
node build/verify-precompiled.mjs