Join our Discord Community

React Bubble Background

Floating bubbles that follow your mouse like a lava lamp came to life. Build mesmerizing React backgrounds with gooey SVG filters, TypeScript support, and smooth spring physics for Next.js applications with shadcn/ui.

Powered by

Trying to implement bubble effects?

Join our Discord community for help from other developers.


Remember lava lamps? This React component creates that same hypnotic effect in your browser. Six bubbles floating, merging, and following your cursor with spring physics. The gooey effect isn't fake—it's real SVG filters making the bubbles merge like actual liquid.

Interactive floating bubbles

Watch bubbles merge and follow your cursor with spring physics:

Loading component...

Built for React applications with TypeScript and Next.js. The bubbles use Motion for smooth animations, while SVG filters create the realistic gooey merging effect. Enable interactive mode and watch them follow your cursor with configurable spring physics.

Installation

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

Usage

import { BubbleBackground } from "@/components/ui/bubble-background";

export default function Hero() {
  return (
    <BubbleBackground interactive={true}>
      <div className="relative z-10">
        <h1>Your content here</h1>
      </div>
    </BubbleBackground>
  );
}

Why most bubble backgrounds look fake

Most developers use basic circles with opacity. They don't merge, they just overlap. Some try to fake it with blur, but it looks flat. Real bubbles merge like liquid, with that characteristic gooey connection when they touch.

This React component uses SVG feGaussianBlur and feColorMatrix filters to create actual metaball effects. When bubbles get close, they merge smoothly like real liquid. Add spring physics for mouse tracking, and you've got bubbles that feel alive, not just animated circles floating around.

Features

  • Real metaball merging with SVG filters creating liquid-like connections
  • Spring physics mouse tracking with configurable stiffness and damping
  • Six customizable bubbles each with unique animation patterns
  • 30-40 second animation cycles for natural, non-repetitive movement
  • TypeScript definitions for all props and configurations
  • Mix-blend-mode effects for color depth and transparency
  • Zero JavaScript animation overhead using CSS animations
  • shadcn/ui compatible with full Tailwind CSS support

API Reference

BubbleBackground

Main container component for the bubble effect.

PropTypeDefaultDescription
interactivebooleanfalseEnable mouse tracking for bubbles
transitionSpringOptions{ stiffness: 100, damping: 20 }Spring physics config for mouse tracking
colorsColorConfigSee belowRGB values for bubble colors
childrenReactNode-Content to display over bubbles
classNamestring-Additional Tailwind CSS classes

Color Configuration

type ColorConfig = {
  first: string;   // RGB like "18,113,255"
  second: string;  // RGB like "221,74,255"
  third: string;   // RGB like "0,220,255"
  fourth: string;  // RGB like "200,50,50"
  fifth: string;   // RGB like "180,180,50"
  sixth: string;   // RGB like "140,100,255"
}

Common gotchas

Performance with filters: SVG filters can be heavy on weak GPUs. The blur and color matrix operations run per frame. Consider disabling on low-end devices.

Mouse tracking lag: Spring physics look smooth but add slight delay. Adjust stiffness (higher = snappier) and damping (lower = bouncier) to taste.

Color format: Colors must be RGB strings like "255,0,0", not hex or named colors. The component injects them as CSS variables.

Z-index layering: Content needs relative z-10. The bubbles sit at base level, filters need specific stacking.

Mobile interaction: Touch doesn't have hover, so interactive mode won't work well. Consider disabling on mobile or using touch events.

You might also like

Explore other animated background components for React applications:

Questions developers actually ask