Scroll Fade
Edge-fade utilities for scroll containers. An edge with more content past it fades out. At the end of the scroll, or when nothing overflows, the edge stays fully opaque.
The fade is CSS only: a scroll-driven animation runs it.
Both edges
Vertical (scroll-fade-y)
Fades the top and bottom edges of a vertically scrolling container. Scroll the list to see each edge fade in and out.
Horizontal (scroll-fade-x)
Fades the left and right edges of a horizontally scrolling container.
Single edge
To fade only one edge, use a single-edge utility. A sidebar, for example, can fade content under a sticky header and stay flush at the bottom. The opposite edge always stays fully opaque.
Use them exactly like the axis utilities: put the edge class on the scroll container. The sidebar example above becomes:
Each box below is pre-scrolled to its midpoint so the single faded edge stands out against the flush opposite edge.
Requirements
- Apply the utility to the scroll container itself: the element that has
overflow-x-autooroverflow-y-auto. The fade follows that element's own scroll position. - The utility sets
mask-image, so don't put anothermask-imageon the same element. - The mask fades everything the element paints, border and background
included. To fade the content of a visible card, put the
border, the background,rounded-*, andoverflow-hiddenon a wrapper. Then put the fade utility on the inner scroll container, as the examples on this page do: