Componentnavigation0.74 KB gzipZero dependencies

ScrollShadow

Wrapper with top/bottom shadow indicators that fade in only when scrollable in that direction; dashed scrollbar styling.

Preview

Live Preview
  • ROW 01 — SCROLL TO SEE STAMP SHADOWS
  • ROW 02 — SCROLL TO SEE STAMP SHADOWS
  • ROW 03 — SCROLL TO SEE STAMP SHADOWS
  • ROW 04 — SCROLL TO SEE STAMP SHADOWS
  • ROW 05 — SCROLL TO SEE STAMP SHADOWS
  • ROW 06 — SCROLL TO SEE STAMP SHADOWS
  • ROW 07 — SCROLL TO SEE STAMP SHADOWS
  • ROW 08 — SCROLL TO SEE STAMP SHADOWS
  • ROW 09 — SCROLL TO SEE STAMP SHADOWS
  • ROW 10 — SCROLL TO SEE STAMP SHADOWS
  • ROW 11 — SCROLL TO SEE STAMP SHADOWS
  • ROW 12 — SCROLL TO SEE STAMP SHADOWS
  • ROW 13 — SCROLL TO SEE STAMP SHADOWS
  • ROW 14 — SCROLL TO SEE STAMP SHADOWS
  • ROW 15 — SCROLL TO SEE STAMP SHADOWS
  • ROW 16 — SCROLL TO SEE STAMP SHADOWS
  • ROW 17 — SCROLL TO SEE STAMP SHADOWS
  • ROW 18 — SCROLL TO SEE STAMP SHADOWS
  • ROW 19 — SCROLL TO SEE STAMP SHADOWS
  • ROW 20 — SCROLL TO SEE STAMP SHADOWS
  • ROW 21 — SCROLL TO SEE STAMP SHADOWS
  • ROW 22 — SCROLL TO SEE STAMP SHADOWS
  • ROW 23 — SCROLL TO SEE STAMP SHADOWS
  • ROW 24 — SCROLL TO SEE STAMP SHADOWS

Installation

Tokens guide →

Add to your project via CLI (zero dependencies, code you own):

npx bigbullui add scroll-shadow

Or install the full npm package:

npm install bigbullui
import { ScrollShadow } from "@/components/ui/scroll-shadow"

<ScrollShadow>
  <div className="p-4 bg-card h-full">Content with scroll</div>
</ScrollShadow>

Usage guidance

Use ScrollShadow when a ticket stub surface needs Wrapper with top/bottom shadow indicators that fade in only when scrollable in that direction; dashed scrollbar styling. Keep props minimal and prefer composition with sibling stubs.

Avoid ScrollShadow for long form flows or dense data grids where a dedicated layout block fits better.

Source code

scroll-shadow.tsx

Zero dependencies (only React + utils). Copy and paste directly into your project:

"use client";

import * as React from "react";
import { cn } from "./lib/utils";

export type ScrollShadowProps = {
  className?: string;
  children?: React.ReactNode;
};

export function ScrollShadow({ className, children }: ScrollShadowProps) {
  const ref = React.useRef<HTMLDivElement>(null);

  React.useEffect(() => {
    const element = ref.current;
    if (!element) return;

    const handleScroll = () => {
      const scrollTop = element.scrollTop;
      const scrollHeight = element.scrollHeight;
      const clientHeight = element.clientHeight;
      const hasScrollTop = scrollTop > 0;
      const hasScrollBottom = scrollTop + clientHeight < scrollHeight;

      if (ref.current === element) {
        const shadowTop = element.parentElement?.querySelector<HTMLElement>("[data-shadow-top]");
        const shadowBottom = element.parentElement?.querySelector<HTMLElement>("[data-shadow-bottom]");

        if (shadowTop) {
          shadowTop.style.opacity = hasScrollTop ? "1" : "0";
        }
        if (shadowBottom) {
          shadowBottom.style.opacity = hasScrollBottom ? "1" : "0";
        }
      }
    };

    element.addEventListener("scroll", handleScroll, { passive: true });
    handleScroll();
    return () => element.removeEventListener("scroll", handleScroll);
  }, []);

  return (
    <div
      
      className={cn(
        "relative h-64 overflow-hidden",
        "motion-reduce:animate-none",
        className,
      )}
    >
      <div ref={ref} className="h-full overflow-auto">
        <div className="relative bg-card p-4">{children}</div>
      </div>
      <div
        className={cn(
          "pointer-events-none absolute top-0 left-0 h-8 w-full bg-gradient-to-b from-border/30 via-transparent to-transparent transition-opacity",
          "motion-reduce:transition-none",
        )}
        data-shadow-top=""
      />

      <div
        className={cn(
          "pointer-events-none absolute bottom-0 left-0 h-8 w-full bg-gradient-to-t from-border/30 via-transparent to-transparent transition-opacity",
          "motion-reduce:transition-none",
        )}
        data-shadow-bottom=""
      />

    </div>
  );
}

Props

PropTypeDescription
classNamestringOptional additional className string.