Scroll Fade

Fade the edges of a scrollable container to hint at overflowing content.

Device 1
Device 2
Device 3
Device 4
Device 5
Device 6
Device 7
Device 8
Device 9
Device 10
Device 11
Device 12
Device 13
Device 14
Device 15
Device 16
Device 17
Device 18
Device 19
Device 20

Ships with the spark styles (utilities.css), so there is no install step. The fade is driven by CSS scroll-driven animations: edges only fade while there is more content to scroll in that direction.

The mask fades everything the element paints, including its own border, so put borders and backgrounds on a wrapper and the scroll-fade class on the inner scroll container.

Usage

ClassEffect
scroll-fade / scroll-fade-yfade top + bottom of a vertical scroller
scroll-fade-xfade both inline edges of a horizontal scroller
scroll-fade-t / scroll-fade-bsingle edge, top / bottom
scroll-fade-l / scroll-fade-rsingle edge, left / right (physical)
scroll-fade-s / scroll-fade-esingle edge, inline start / end (RTL-aware)
scroll-fade-<n> / scroll-fade-[2rem]fade size (spacing scale / arbitrary)
scroll-fade-t-<n>scroll-fade-e-<n>per-edge fade size
scroll-fade-nonedisable (e.g. md:scroll-fade-none)

no-scrollbar (also in utilities.css) hides the native scrollbar when the fade alone should hint at overflow.

Examples

Horizontal

Device 1
Device 2
Device 3
Device 4
Device 5
Device 6
Device 7
Device 8

Single edge + fade size

Fade only the bottom, sized via the spacing scale (scroll-fade-b-16).

Device 1
Device 2
Device 3
Device 4
Device 5
Device 6
Device 7
Device 8
Device 9
Device 10
Device 11
Device 12
Device 13
Device 14
Device 15
Device 16
Device 17
Device 18
Device 19
Device 20

Fallback

Where animation-timeline: scroll() is unsupported, the fade is static (edges stay faded regardless of scroll position), so content is never hidden without a hint.

On this page