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.

Search now matches on tags.

Tables keep the first column in view.

Dark mode reaches the settings page.

Invoices export as PDF.

Teams can pin a project to the top.

Shortcuts show in every menu.

Uploads resume after a lost connection.

Comments support mentions.

The sidebar remembers its width.

Charts load before the table does.

Filters save to a link you can share.

Billing emails go to more than one address.

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.
viewportRefReact.Ref<HTMLDivElement>NoneA ref to the scrolling viewport, for a caller that reads or drives the scroller itself: scrollTop to centre on a row, a scroll listener, a scrollTo from an edge button.
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.
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.
skimHeightnumber = 24Size 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.
viewportRefReact.Ref<HTMLDivElement>A ref to the scrolling viewport, for a caller that reads or drives the scroller itself: scrollTop to centre on a row, a scroll listener, a scrollTo from an edge button.
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.