Skip to content

Magnetic Grid

A grid that bends and lights up around the pointer.

LIVE PREVIEWInteract with the component
Install dependencies

npm install @react-three/fiber three

CSS Modules

Usage

Matches your current playground settings.

jsx
import MagneticGrid from "./MagneticGrid";
export default function Example() {
return (
<MagneticGrid
gridScale={1}
distortion={0.75}
glow={0.65}
nodes={true}
vignette={true}
colorA={"#7CF7FF"}
colorB={"#FF6BDE"}
bg={"#080A10"}
minHeight={420}
/>
);
}

Using Magnetic Grid

Use gridScale to set the grid density and minHeight to reserve the effect's area.

distortion changes the pointer response while glow changes the brightness. Keep both restrained when placing readable content over the grid.

Props

NameTypeRequiredDefaultDescription
classNamestringNoundefinedAdditional CSS class names, merged with base component styles.
minHeightnumber | stringNo420Minimum height for the component container. Accepts a number (pixels) or any valid CSS height string.
gridScalenumberNo1Overall grid density and scale multiplier.
distortionnumberNo0.75Strength of the magnetic field distortion (0 to 1).
glownumberNo0.65Glow intensity applied to grid lines and nodes (0 to 1).
nodesbooleanNotrueWhether to show glowing grid intersections.
vignettebooleanNotrueWhether to apply a soft vignette on the edges.
colorAstringNo"#7CF7FF"Primary grid color.
colorBstringNo"#FF6BDE"Secondary grid color for the gradient blend.
bgstringNo"#080A10"Background color behind the grid.
mouseRefReact.MutableRefObject<{ x: number; y: number }>NoundefinedOptional pointer ref for external cursor tracking, values in the range [-1, 1].
onClick(event: React.MouseEvent) => voidNoundefinedOptional click handler for the root element.

Related components

Glacial Rift

Backgrounds

Sculpted ice walls frame a luminous, slowly shifting blue crevasse.

Solar Veil

Backgrounds

Copper light curtains hang in fine, flowing folds above a dark horizon.

Opal Current

Backgrounds

Pearlescent liquid folds shift between jade, rose and soft silver.

Event Horizon

Backgrounds

A dark celestial silhouette bends warm orbital threads into a glowing disc.