scroll-fade

Utilities for adding a fade effect to the edges of a scroll container.

Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
Item 9
Item 10
Item 11
Item 12

Usage

Class Behavior
scroll-fadeFade the top and bottom edges.
scroll-fade-yFade the top and bottom edges.
scroll-fade-xFade the logical start and end edges.
scroll-fade-tFade only the top edge.
scroll-fade-bFade only the bottom edge.
scroll-fade-lFade only the physical left edge.
scroll-fade-rFade only the physical right edge.
scroll-fade-sFade the logical start edge; mirrors in RTL.
scroll-fade-eFade the logical end edge; mirrors in RTL.
scroll-fade-<number>Set the fade size from the spacing scale.
scroll-fade-[<value>]Set an arbitrary fade size.
scroll-fade-{t,b,s,e}-<number>Set one edge size from the spacing scale.
scroll-fade-{t,b,s,e}-[<value>]Set an arbitrary size for one edge.
scroll-fade-noneRemove the fade mask.

The fade follows the scroll position:

  • At the start, the top edge stays crisp while the bottom fades to signal more content.
  • After scrolling, the top fade appears; both edges remain faded through the middle.
  • At the final item, the bottom fade clears to show that the list has ended.

The mask belongs on the inner scrolling viewport. Keep borders, radii, and backgrounds on an outer wrapper so only the content dissolves.

Installation

Copy plugins/scroll-fade.js into your Tailwind v3 project, then register it in tailwind.config.cjs.

module.exports = {
  plugins: [require("./plugins/scroll-fade")],
}

No Overflow, No Fade

Content that fits remains crisp. The utility can stay applied without checking whether the list overflows.

Item 1
Item 2
Item 3

Horizontal Scrolling

Use scroll-fade-x on the inner element that owns horizontal overflow.

Edge Fades

Use an edge utility when only one edge should track scrolling.

Inbox triage
Design review
API contract
QA pass
Launch notes
Metrics follow-up
scroll-fade-t
Inbox triage
Design review
API contract
QA pass
Launch notes
Metrics follow-up
scroll-fade-b
Design Engineering Marketing Product Research
scroll-fade-s
Design Engineering Marketing Product Research
scroll-fade-e

Fade Size

The default is 12% of the viewport, capped at 40px. Use the spacing scale or an arbitrary value to override it.

Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
scroll-fade-4
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
scroll-fade-24

Disabling the Fade

Add scroll-fade-none to remove the mask without changing the scroll layout.

Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
scroll-fade
Item 1
Item 2
Item 3
Item 4
Item 5
Item 6
Item 7
Item 8
scroll-fade scroll-fade-none