Background

Bubble Background

Animated bubble background with interactive mouse tracking and customizable colors. Perfect for React applications requiring dynamic backgrounds with Next.js integration and TypeScript support.

Powered by

Loading component...

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

Features

  • Fluid bubble animations with rotating, scaling, and floating motion patterns using Motion
  • Interactive mouse tracking with spring physics that follow cursor movement for engaging UX
  • SVG filter effects using Gaussian blur and color matrix for realistic gooey bubble merging
  • Customizable color palette with six configurable RGB color values for unique visual themes
  • Blend modes using CSS mix-blend-mode for seamless color mixing and depth effects
  • TypeScript support with complete interface definitions for all animation and styling props

Use Cases

This free open source React component works well for:

  • Landing pages - Dynamic hero backgrounds that capture attention in Next.js applications
  • Creative portfolios - Artistic backgrounds for showcasing work using TypeScript and Tailwind CSS
  • Dashboard layouts - Subtle animated backgrounds that don't interfere with content readability
  • Loading screens - Engaging visuals during data fetching and application initialization

API Reference

BubbleBackground

PropTypeDefaultDescription
interactivebooleanfalseEnable mouse tracking for interactive bubble following cursor
transitionSpringOptions{ stiffness: 100, damping: 20 }Spring physics configuration for mouse tracking animation
colorsColorConfigDefault paletteRGB color values for six animated bubbles
childrenReact.ReactNode-Content to overlay on top of the bubble background
classNamestring-CSS classes for container styling and positioning

Color Configuration

Default color palette (RGB values):

  • first - "18,113,255" (Blue)
  • second - "221,74,255" (Purple)
  • third - "0,220,255" (Cyan)
  • fourth - "200,50,50" (Red)
  • fifth - "180,180,50" (Yellow)
  • sixth - "140,100,255" (Violet)

Animation Patterns

  • Vertical floating - 30-second cycles with easeInOut timing
  • Circular rotation - 20 and 40-second linear rotations with different origins
  • Horizontal oscillation - 40-second horizontal movement patterns
  • Mouse following - Real-time spring physics responding to cursor position

Implementation Notes

  • Uses CSS custom properties for dynamic color injection
  • SVG filter creates realistic bubble merging effects with feGaussianBlur
  • Mouse tracking calculates relative position from container center
  • All animations use infinite repeat for continuous motion
  • Overflow hidden prevents bubbles from extending beyond container
  • Compatible with all standard div HTML attributes and event handlers