Scroll container that fades the edge on the side where there is more to scroll, so users see that the content continues. The fade is a CSS mask driven by a scroll timeline, no JavaScript. Works horizontally and vertically. With a mouse the row scrolls with the wheel and the arrow buttons at the edges, with a trackpad or a finger by swipe, with the keyboard by the arrow keys after Tab. The wheel handler and the arrows are the only client part: a ref callback and a small island that calls scrollBy on click.
Browser Support
Animates elements while scrolling
Animates the fading edges
Creates fading edges
Styles the focused scroller
Adapts scrolling to JavaScript availability
Hides the scrollbar
Contains scroll gestures
Preview
Scroll the table sideways: the left edge fades in, the right one fades out at the end. Scroll with the wheel or the arrows over a mouse, with a swipe on touch screens, or focus the table with Tab and use the arrow keys.
| Plan | Price | Projects | Storage | Members | History | Support | Domains | API calls |
|---|---|---|---|---|---|---|---|---|
| Starter | $0 | 3 | 1 GB | 1 | 7 days | Forum | - | 1k / day |
| Team | $12 | 20 | 50 GB | 10 | 90 days | 1 | 50k / day | |
| Business | $39 | Unlimited | 500 GB | 50 | 1 year | Chat | 5 | 500k / day |
| Enterprise | Custom | Unlimited | Custom | Unlimited | Forever | Manager | Unlimited | Custom |
Installation
Usage
import { FadeScroller } from "@/components/ui/fade-scroller"
export default function Example() {
return (
<FadeScroller label="Pricing table" className="rounded-lg border">
<table className="w-full text-sm">{/* wide table */}</table>
</FadeScroller>
)
}Examples
Row of chips
A wider fade and a hidden scrollbar suit tags and filters. Narrow the window to see the edges.
import { Button } from "@/components/ui/button"
<FadeScroller label="Topics" hideScrollbar fadeSize={56}>
<div className="flex gap-2">
{topics.map((topic) => (
<Button key={topic} className="shrink-0 rounded-full border px-3">
{topic}
</Button>
))}
</div>
</FadeScroller>Vertical list
orientation="vertical" fades the top and bottom edges. The root needs a fixed height.
- Deployed preview7 min ago
- Merged pull request14 min ago
- Opened issue21 min ago
- Updated settings28 min ago
- Invited member35 min ago
- Rotated key42 min ago
- Archived project49 min ago
- Renamed branch56 min ago
- Restored backup63 min ago
- Changed plan70 min ago
- Exported report77 min ago
- Added domain84 min ago
<FadeScroller orientation="vertical" label="Activity" className="h-64">
<ul className="divide-y">{/* items */}</ul>
</FadeScroller>Arrow step
scrollStep sets how far one arrow click scrolls, as a share of the visible size. 1 turns the list page by page.
<FadeScroller
orientation="vertical"
label="Terms of service"
scrollStep={1}
className="h-80 rounded-lg border"
>
<article className="prose p-4">{terms}</article>
</FadeScroller>Props
| Prop | Type | Default | Description |
|---|---|---|---|
| orientation | "horizontal" | "vertical" | "horizontal" | Scroll axis |
| fadeSize | number | 40 | Width of the faded edge in px |
| showArrows | "auto" | boolean | "auto" | "auto" shows the arrows only on devices with a mouse and only when there is more to scroll, true shows them everywhere, false hides them |
| wheel | boolean | true | The vertical mouse wheel scrolls a horizontal row. Gives the wheel back to the page at the edges and leaves trackpads, Shift and Ctrl alone |
| scrollStep | number | 0.8 | Arrow step as a fraction of the visible size |
| hideScrollbar | boolean | false | Hide the native scrollbar |
| label | string | "Scrollable content" | Name of the scroll region for screen readers |
| labels | Partial<FadeScrollerLabels> | English | Arrow button labels |
| viewportClassName | string | - | Classes for the scrolling element |
| className | string | - | Classes for the root |
Features
- No JavaScript for the fades: a scroll timeline drives the mask, the browser does it off the main thread
- Mask instead of overlay: the fade works on any background, no gradient color to match
- Keyboard: the area always has tabIndex, role="region" and a label, so it scrolls with the arrow keys
- Mouse, trackpad, keyboard: the wheel scrolls the row sideways, trackpads and touch work natively, the arrow keys scroll the focused area, no drag so clicks on the content stay intact
- RTL: start and end follow the text direction
- Reduced motion: arrow clicks scroll instantly instead of smoothly