An interactive background featuring smoothly animated gradient bubbles, creating a playful, dynamic, and visually engaging backdrop.
Installation
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
| Prop | Type | Default |
|---|---|---|
interactive? | boolean | false |
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
- Credits to GlitchWorker for the inspiration