Join our Discord Community

Gradient Animation Background

Flowing gradients that dance like aurora in a digital sky. Build mesmerizing React backgrounds with animated orbs, mouse tracking, TypeScript support, and CSS blend modes for Next.js applications with shadcn/ui.

Trying to implement gradient animations?

Join our Discord community for help from other developers.


Static gradients are everywhere. CSS linear-gradient this, radial-gradient that. Boring. What if your gradients could move, breathe, respond to your cursor? This React component creates five animated orbs that float around your background, blending colors like paint drops in water, with an extra orb that follows your mouse.

Dynamic flowing gradients

Watch orbs dance with independent movement and mouse interaction:

Loading component...

Built for React applications with TypeScript and Next.js. The orbs use CSS animations with different timing cycles (20-40 seconds), creating organic movement that never repeats exactly. Blend modes make colors interact naturally, and mouse tracking adds that interactive spark.

Installation

npx shadcn@latest add https://www.shadcn.io/registry/background-gradient-animation.json
npx shadcn@latest add https://www.shadcn.io/registry/background-gradient-animation.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/background-gradient-animation.json
bunx shadcn@latest add https://www.shadcn.io/registry/background-gradient-animation.json

Usage

import { BackgroundGradientAnimation } from "@/components/ui/background-gradient-animation";

export default function Hero() {
  return (
    <BackgroundGradientAnimation
      gradientBackgroundStart="rgb(108, 0, 162)"
      gradientBackgroundEnd="rgb(0, 17, 82)"
      firstColor="18, 113, 255"
      secondColor="221, 74, 255"
      thirdColor="100, 220, 255"
      fourthColor="200, 50, 50"
      fifthColor="180, 180, 50"
      pointerColor="140, 100, 255"
      blendingValue="hard-light"
      interactive={true}
    >
      <div className="absolute z-50 inset-0 flex items-center justify-center text-white font-bold px-4 pointer-events-none text-3xl text-center md:text-4xl lg:text-7xl">
        <p className="bg-clip-text text-transparent drop-shadow-2xl bg-gradient-to-b from-white/80 to-white/20">
          Gradients in Motion
        </p>
      </div>
    </BackgroundGradientAnimation>
  );
}

Why most gradient animations look cheap

Most developers use keyframe animations to shift background-position or hue-rotate. It looks artificial—too smooth, too predictable. Some try JavaScript to animate gradient stops, but that's performance hell. Real organic movement has layers, depth, and unpredictable interactions.

This React component creates depth with five independent orbs, each following different animation paths. CSS blend modes (hard-light, screen, overlay) make colors interact like real light mixing. The mouse-following orb adds interactivity without being distracting. No canvas, no complex calculations—just smart CSS and React working together.

Features

  • Five independent animated orbs with 20-40 second movement cycles
  • Interactive mouse tracking with smooth cursor-following orb
  • CSS blend modes creating natural color mixing (hard-light, screen, overlay, multiply, color-dodge)
  • Customizable color system supporting full RGB control for all elements
  • Safari optimizations with SVG filter fallbacks for cross-browser support
  • TypeScript definitions for all props and color configurations
  • Performance optimized using pure CSS animations
  • shadcn/ui compatible with proper content layering

API Reference

BackgroundGradientAnimation

Main container component for the gradient animation effect.

PropTypeDefaultDescription
gradientBackgroundStartstring"rgb(108, 0, 162)"Starting color of background gradient
gradientBackgroundEndstring"rgb(0, 17, 82)"Ending color of background gradient
firstColorstring"18, 113, 255"RGB values for first orb (no rgb() wrapper)
secondColorstring"221, 74, 255"RGB values for second orb (no rgb() wrapper)
thirdColorstring"100, 220, 255"RGB values for third orb (no rgb() wrapper)
fourthColorstring"200, 50, 50"RGB values for fourth orb (no rgb() wrapper)
fifthColorstring"180, 180, 50"RGB values for fifth orb (no rgb() wrapper)
pointerColorstring"140, 100, 255"RGB values for mouse-tracking orb
sizestring"80%"Size of the animated orbs
blendingValuestring"hard-light"CSS mix-blend-mode for color mixing
interactivebooleantrueEnable mouse tracking for pointer orb
childrenReactNode-Content to display over the animation
classNamestring-Additional CSS classes for content wrapper
containerClassNamestring-Additional CSS classes for main container

Color Format

// Orb colors: RGB values without rgb() wrapper
firstColor = "255, 0, 128"; // Pink
secondColor = "0, 255, 128"; // Green

// Background colors: Full CSS color values
gradientBackgroundStart = "rgb(45, 212, 191)";
gradientBackgroundEnd = "hsl(240, 100%, 20%)";

Available Blend Modes

  • hard-light (default) - Strong color mixing
  • screen - Bright, luminous effect
  • overlay - Balanced color blending
  • multiply - Darker color mixing
  • color-dodge - Intense bright highlights

Common gotchas

Color format confusion: Orb colors need RGB values without the rgb() wrapper ("255, 0, 128"), but background gradients use full CSS color syntax ("rgb(255, 0, 128)").

Z-index layering: Your content needs absolute z-50 or higher to appear above the animation. The orbs use lower z-index values for proper layering.

Performance with many props: Each color change triggers a re-render. For dynamic color changing, consider using CSS variables instead of props.

Blend mode browser support: Most blend modes work everywhere, but color-dodge might not work in very old browsers. hard-light is the safest default.

Mouse tracking on mobile: Touch devices don't have hover, so the interactive orb won't track touches. The other orbs still animate normally.

You might also like

Explore other flowing background components for React applications:

Questions developers actually ask