kevingirelli

Scroll Background

Backgrounds

About

A background that blends from one color to the next as the page or a scroll box scrolls, built with CSS scroll-driven animations and no JavaScript.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds Scroll Background to your project and fits it to your theme.

Code

How Scroll Background is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import { ScrollBackground } from "@/components/ui/scroll-background";

const watches = [
  { name: "Morning watch", time: "04:00 to 08:00" },
  { name: "Forenoon watch", time: "08:00 to 12:00" },
  { name: "Afternoon watch", time: "12:00 to 16:00" },
  { name: "Dog watches", time: "16:00 to 20:00" },
  { name: "First watch", time: "20:00 to 00:00" },
  { name: "Middle watch", time: "00:00 to 04:00" },
];

export default function ScrollBackgroundDemo() {
  return (
    <div className="flex h-[28rem] w-full items-center justify-center bg-background p-6">
      <div
        className="h-80 w-full max-w-md overflow-y-auto rounded-lg border"
        tabIndex={0}
        role="region"
        aria-label="Watches"
      >
        <ScrollBackground
          timeline="nearest"
          colors={[
            "var(--background)",
            "color-mix(in srgb, #0ea5e9 24%, var(--background))",
            "color-mix(in srgb, #f59e0b 24%, var(--background))",
            "color-mix(in srgb, #6366f1 24%, var(--background))",
          ]}
          className="text-foreground"
        >
          {watches.map((watch) => (
            <div
              key={watch.name}
              className="grid h-32 content-center gap-1 px-6"
            >
              <p className="text-2xl font-semibold">{watch.name}</p>
              <p className="font-mono text-sm text-muted-foreground">
                {watch.time}
              </p>
            </div>
          ))}
        </ScrollBackground>
      </div>
    </div>
  );
}

More by kevingirelli

View all
  • Aurora

    Aurora

    48
  • Warp Gradient

    Warp Gradient

    47
  • FAQ Section

    FAQ Section

    44
  • QR Code

    QR Code

    42
  • Wave Text

    Wave Text

    36
  • Corner Frame

    Corner Frame

    33
  • Animated Border

    Animated Border

    30
  • Spotlight

    Spotlight

    23

More in Backgrounds

View all
  • Elegant Dark Pattern

    Elegant Dark Pattern

    807
  • Gradient Backgrounds

    Gradient Backgrounds

    25
  • Background snippets

    Background snippets

    105
  • Background Components

    Background Components

    20
  • Jade Sky

    Jade Sky

    84
  • Tailwind CSS Background Snippet

    Tailwind CSS Background Snippet

    532
  • CosmicNebula

    CosmicNebula

    8
  • Dark Gradient Background

    Dark Gradient Background

    144