AnimationUpdated in v15

Waves

Drifting lines behind your content that bend around the pointer.

Installation

Import the class, and @use the entry point in your global styles: without it the component renders unstyled.

import { Component } from '@angular/core';
import { WrWaves } from 'ngwr/bits/waves';

@Component({ imports: [WrWaves] })
export class MyComponent {}
Angular adaptation of an effect by David Haz / reactbits.dev.

Playground

Put it in a positioned box; it fills that box behind the content.

Content above the waves

<section style="position: relative">
  <wr-waves [waveAmpX]="32" [waveAmpY]="16" [xGap]="10" [yGap]="32" />
  <h1>Content above the waves</h1>
</section>

Customize

Amp X
32
Amp Y
16
X Gap
10
Y Gap
32

API

NameDescriptionTypeDefault
lineColorLine colour. Unset, it follows the theme.string | nullnull
backgroundColorFill behind the lines.string'transparent'
waveSpeedXHorizontal noise drift per ms.number0.0125
waveSpeedYVertical noise drift per ms.number0.005
waveAmpXHorizontal wave amplitude (px).number32
waveAmpYVertical wave amplitude (px).number16
xGapGap between lines (px).number10
yGapGap between points on a line (px).number32
frictionCursor-spring damping, 0..1.number0.925
tensionCursor-spring pull-back strength.number0.005
maxCursorMoveMax px a point drags from rest.number100

CSS variables

Set these on the component's selector or a wrapper, not on :root: the defaults are declared on ngwr/bits/waves's own element.

VariableDefaultDeclared on
--wr-waves-line-colorlight-dark(color-mix(in srgb, var(--wr-color-on-surface) 12%, transparent), rgb(255 255 255 / 14%)).wr-waves
--wr-waves-x-gap10px.wr-waves

See also