Modus UI

Waves

Web (React)

A reactive background of flowing lines driven by Perlin noise and cursor physics.

A physics-based line wave background that utilizes Perlin noise and cursor proximity to disturb the wave field dynamically.

Wave Dynamics

Move your mouse around to physically disturb the Perlin noise wave field.

Installation

CLI

npx @modus-ui/cli add waves

Manual

  1. Copy the code from the component tab.
  2. Create a file at components/ui/waves.tsx.
  3. Paste the code.

Usage

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

export default function Example() {
  return (
    <div className="relative h-[500px] w-full overflow-hidden">
      <Waves
        lineColor="rgba(55, 50, 47, 0.2)"
        waveSpeedX={0.02}
        waveSpeedY={0.01}
        waveAmpX={40}
        waveAmpY={20}
      />
      <div className="relative z-10 flex h-full items-center justify-center">
        <h1>Content over waves</h1>
      </div>
    </div>
  );
}

Props

PropTypeDefaultDescription
lineColorstring"rgba(0, 0, 0, 0.2)"Colour of the wave lines.
backgroundColorstring"transparent"Background colour behind the lines.
waveSpeedXnumber0.0125Horizontal speed of the noise field.
waveSpeedYnumber0.005Vertical speed of the noise field.
waveAmpXnumber32Horizontal amplitude of the waves.
waveAmpYnumber16Vertical amplitude of the waves.
xGapnumber10Horizontal gap between lines in pixels.
yGapnumber32Vertical gap between points in pixels.
frictionnumber0.925How quickly cursor-induced motion settles.
tensionnumber0.005How strongly points spring back to rest.
maxCursorMovenumber100Maximum displacement caused by the cursor in pixels.
styleReact.CSSProperties{}Inline styles for the container.

Comments

  • No comments yet.