AnimationAdded in v15.1

Dot Grid

A field of dots behind your content that lights up and moves aside near 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 { WrDotGrid } from 'ngwr/bits/dot-grid';

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

Playground

Put it in a positioned box; it fills that box and follows the pointer over the content in front of it.

Content above the dots

<section style="position: relative; min-height: 18rem; overflow: hidden">
  <wr-dot-grid
    [dotSize]="3"
    [gap]="24"
    [radius]="120"
    [strength]="12"
  />
  <h1 style="position: relative">Content above the dots</h1>
</section>

Customize

Dot size
3.0 px
Gap
24 px
Radius
120 px
Strength
12 px
Dot colour
Active colour

Light only

A strength of 0 keeps every dot in place. Colours take any CSS colour, a theme token included, and follow the colour scheme.

<section style="position: relative; min-height: 12rem; overflow: hidden">
  <wr-dot-grid activeColor="var(--wr-color-success)" [strength]="0" [gap]="18" />
</section>

API

NameDescriptionTypeDefault
dotSizeDot diameter (px).number3
gapDistance between dot centres (px), never under 4.number24
dotColorResting dot colour. Unset, it follows the theme.string | nullnull
activeColorColour a dot takes near the pointer. Unset, it follows the theme.string | nullnull
radiusHow far from the pointer a dot still reacts (px).number120
strengthHow far a dot by the pointer is pushed (px). 0 only lights it; negative pulls it in.number12

CSS variables

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

VariableDefaultDeclared on
--wr-dot-grid-active-colorvar(--wr-color-primary).wr-dot-grid
--wr-dot-grid-dot-colorvar(--wr-border-strong).wr-dot-grid
--wr-dot-grid-dot-size3px.wr-dot-grid
--wr-dot-grid-gap24px.wr-dot-grid

See also