Join our Discord Community

React Waves Background

Fluid ocean-like animations with interactive physics and Perlin noise algorithms. Build mesmerizing React wave backgrounds with cursor-responsive dynamics, customizable parameters, and TypeScript support for Next.js applications with shadcn/ui.

Creating fluid, ocean-like interfaces?

Join our Discord community for help from other developers.


Static backgrounds feel lifeless. Digital. Artificial. But water flows with organic grace—waves that respond to touch, ripple with natural physics, move with the rhythm of tides. This React component recreates that fluid magic using Perlin noise algorithms and interactive physics that make your interface feel alive and responsive.

Interactive fluid wave physics

Watch waves flow and respond to cursor movement with realistic spring dynamics:

Loading component...

Built for React applications with TypeScript and Next.js. Uses HTML5 Canvas with Perlin noise for smooth, natural wave generation that never feels mechanical. Interactive physics respond to mouse movement with configurable spring tension and friction. Perfect for hero sections, creative portfolios, or any interface that needs organic fluidity.

Installation

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

Usage

import { Waves } from "@/components/ui/waves";

export default function OceanicHero() {
  return (
    <div className="relative h-screen w-full overflow-hidden">
      {/* Fluid wave background */}
      <Waves
        lineColor="rgba(59, 130, 246, 0.6)"
        backgroundColor="#0f172a"
        waveSpeedX={0.02}
        waveSpeedY={0.01}
        waveAmpX={40}
        waveAmpY={20}
        friction={0.9}
        tension={0.01}
        className="absolute inset-0"
      />
      
      {/* Your content flows above */}
      <div className="relative z-10 flex items-center justify-center h-full">
        <div className="text-center text-white">
          <h1 className="text-6xl font-bold mb-4">
            Dive Into Fluidity
          </h1>
          <p className="text-xl opacity-80">
            Where digital meets organic
          </p>
        </div>
      </div>
    </div>
  );
}

Why most wave animations look fake

Most developers use simple sine waves with Math.sin() and Math.cos()—creating perfect, predictable patterns that scream "computer generated." Others try CSS animations, but they're rigid and lack the organic chaos of real water. Some use video backgrounds, but they're heavy and never interactive.

This React component uses Perlin noise algorithms—the same math behind natural terrain and fluid simulations. Each wave point follows smooth, continuous curves that flow like real water. Interactive physics with spring tension and friction make waves respond naturally to cursor movement. It's the difference between a digital pattern and living water.

Features

  • Perlin noise algorithms creating smooth, organic wave patterns that flow like real water
  • Interactive physics system with spring tension and friction responding to cursor movement
  • Canvas-based rendering using efficient HTML5 Canvas with 60fps requestAnimationFrame
  • Customizable wave parameters controlling speed, amplitude, spacing, and physics properties
  • Touch-friendly interactions supporting both desktop mouse and mobile touch events
  • Theme-aware color system adapting automatically to light/dark themes with CSS variables
  • Content overlay support with proper z-index management for floating UI elements
  • Responsive container adaptation automatically adjusting to window and container changes
  • Performance optimized using efficient canvas operations and smooth animation loops
  • TypeScript definitions for all wave physics and visual customization parameters
  • shadcn/ui compatible with seamless integration and theme support

Examples

Subtle Ambient Waves

Gentle flowing motion perfect for background ambience:

Loading component...

API Reference

Waves

Main component for interactive canvas-based fluid wave animations with Perlin noise.

PropTypeDefaultDescription
lineColorstring"hsl(var(--foreground))"Color of the wave lines
backgroundColorstring"white"Background color of the container
waveSpeedXnumber0.0125Horizontal wave animation speed
waveSpeedYnumber0.005Vertical wave animation speed
waveAmpXnumber32Horizontal wave amplitude
waveAmpYnumber16Vertical wave amplitude
xGapnumber10Horizontal spacing between wave lines
yGapnumber32Vertical spacing between wave points
frictionnumber0.925Physics friction coefficient (0-1)
tensionnumber0.005Spring tension for cursor interaction
maxCursorMovenumber100Maximum cursor influence distance
classNamestring-Additional CSS classes

Perlin Noise Configuration

Wave generation uses multi-octave Perlin noise for organic patterns:

// Natural wave generation
const noiseX = perlin.noise(x * 0.01, time * waveSpeedX);
const noiseY = perlin.noise(y * 0.01, time * waveSpeedY);

// Amplitude controls wave height
const waveHeight = noiseY * waveAmpY;
const waveWidth = noiseX * waveAmpX;

Physics Parameter Guidelines

// Gentle ocean waves
waveSpeedX={0.005} waveSpeedY={0.002} friction={0.95} tension={0.002}

// Active interactive waves
waveSpeedX={0.02} waveSpeedY={0.01} friction={0.9} tension={0.01} // Default

// Energetic stormy seas
waveSpeedX={0.04} waveSpeedY={0.02} friction={0.85} tension={0.02}

// Chaotic turbulent water
waveSpeedX={0.06} waveSpeedY={0.03} friction={0.8} tension={0.03}

Color and Theme Examples

// Ocean blue theme
<Waves
  lineColor="rgba(59, 130, 246, 0.6)" 
  backgroundColor="#0f172a"
/>

// Warm sunset waves
<Waves
  lineColor="rgba(251, 146, 60, 0.7)" 
  backgroundColor="#1e1b4b"
/>

// Monochrome elegance
<Waves
  lineColor="rgba(0, 0, 0, 0.3)" 
  backgroundColor="white"
/>

// Neon cyberpunk
<Waves
  lineColor="rgba(34, 197, 94, 0.8)" 
  backgroundColor="#000000"
/>

Common gotchas

Perlin noise performance: The smooth noise calculations are more expensive than simple sine waves. Very high frequencies (waveSpeedX/Y > 0.05) can impact performance on older devices.

Physics parameter balance: High tension (>0.02) with low friction (<0.8) can create jittery, unrealistic movement. Balance is key for natural wave physics.

Canvas sizing precision: The canvas must match container dimensions exactly for accurate cursor interaction. Mismatched sizes cause waves to respond incorrectly to mouse position.

Color format requirements: Use rgba() format for line colors to control opacity. Solid colors might overwhelm content layered above the waves.

Mobile touch behavior: Touch events don't have hover states like mouse. Waves will respond to touch but won't "follow" finger movement continuously.

Theme integration challenges: Default colors use CSS custom properties. If waves appear invisible, check that your theme defines proper foreground/background contrast.

You might also like

Explore other fluid and organic background components for React applications:

Questions developers actually ask