UI.MD

Scroll Fade

A scrollable container with gradient fade edges to indicate overflow.

Installation

$
npx shadcn@latest add https://ui.mattdowney.com/r/scroll-fade.json

Usage

import { ScrollFade } from "@/components/ui/scroll-fade"

Examples

Default

A scrolling region whose edges fade, so it is obvious there is more above or below. The height goes on ScrollFade itself: with nothing bounding it there is no overflow and no fade.

Scrollable item 1

Scrollable item 2

Scrollable item 3

Scrollable item 4

Scrollable item 5

Scrollable item 6

Scrollable item 7

Scrollable item 8

Scrollable item 9

Scrollable item 10

Scrollable item 11

Scrollable item 12

Horizontal

A single line that runs past the edge scrolls sideways under the same overlay thumb. The content is w-max min-w-full, and its trailing padding is the room that lets the last characters clear the right skim.

npx shadcn@latest add -o https://ui.mattdowney.com/r/kit.json

API Reference

PropTypeDefaultDescription
orientation"vertical" | "horizontal""vertical"The axis that scrolls. horizontal fades the left and right edges and runs the thumb along the bottom. The content has to be wider than the region to overflow, so give it w-max min-w-full.
skimHeightnumber24Size of the gradient fade skim at each edge along the scroll axis, in pixels (a width when orientation is horizontal). The fade ramps in with scroll distance, solid at a fully scrolled edge; nothing is reserved at rest.
fade"both" | "start" | "end" | "top" | "bottom""both"Which edges show the fade skim. Use bottom when the container has a frozen header (Table stickyHeader): a top skim would fade the sticky header as rows scroll under it. start and end are the orientation-neutral spellings of top/left and bottom/right.