DotField

A grid of dots that swells and shrinks away from the pointer, then springs home. One canvas, asleep when nothing moves. Effects.

Open playground
Move your pointer across the grid

About

DotField is a React component in the Effects category of smoui. It is typed, ships no stylesheet, follows your theme through CSS variables, and honors prefers-reduced-motion. Import it with import { DotField } from "@ashutoshswamy/smoui" and set children, gap, radius among its 5 props.

Install

Terminal
npm i @ashutoshswamy/smoui

Usage

TSX
import { DotField } from "@ashutoshswamy/smoui";

<DotField className="h-64 rounded-3xl" gap={24} radius={120}>
  <h2>Move your pointer</h2>
</DotField>

Props 5

children

Content shown above the dots.

ReactNode
gap

Distance between dots. Default 24.

number
radius

Reach of the push. Default 120.

number
strength

0-2, how hard dots are shoved. Default 1.

number
size

Resting dot radius. Default 1.6.

number