Bubble Background

An interactive background featuring smoothly animated gradient bubbles, creating a playful, dynamic, and visually engaging backdrop.

"use client"

import { BubbleBackground } from "@/components/animate-ui/backgrounds/bubble"

export default function BubbleBackgroundDemo({
  interactive = true,
}: {
  interactive?: boolean
}) {
  return (
    <BubbleBackground interactive={interactive} className="absolute inset-0" />
  )
}

Installation

npx shadcn@latest add @animate-ui/backgrounds-bubble
pnpm dlx shadcn@latest add @animate-ui/backgrounds-bubble
yarn dlx shadcn@latest add @animate-ui/backgrounds-bubble
bun x shadcn@latest add @animate-ui/backgrounds-bubble

Usage

import { BubbleBackground } from '@/components/animate-ui/backgrounds/bubble';

export function Hero() {
  return (
    <section className="relative h-[480px] overflow-hidden">
      <BubbleBackground className="absolute inset-0" />
    </section>
  );
}

Animation

  • Five blurred, color-blended bubbles move on slow loops: two drift 100px back and forth (30s and 40s, eased in and out), three orbit around points off to the side (full turns in 20s, 40s and 20s, linear).
  • With interactive, a sixth bubble follows the mouse on a spring (transition), relative to the center of the container. On touch screens, a tap moves it too.
  • The loops pause off screen and while the tab is hidden.
  • Under reduced motion, the bubbles hold a still frame and the follower stays put.

API Reference

BubbleBackground

PropTypeDefault
interactive?
booleanfalse
transition?
SpringOptions{ stiffness: 100, damping: 20 }
colors?
{ first: string; second: string; third: string; fourth: string; fifth: string; sixth: string }{ first: '18,113,255', second: '221,74,255', third: '0,220,255', fourth: '200,50,50', fifth: '180,180,50', sixth: '140,100,255' }
...props?
React.ComponentProps<'div'>-

Credits

Built by Skyleen. The source code is available on GitHub.

Last updated: 10/18/2026

On this page