Repelling Grid
An interactive dot-grid background whose dots move away from the cursor.
Updated Added Changelog
Preview
Move the cursor. Click for ripples.
Installation
pnpm dlx shadcn@latest add @satoriui/repelling-gridAdds components/satori-ui/repelling-grid.tsx to your project and installs its dependencies.
Usage
Examples
On a light section
Give it a light background class and a dark colour, and raise brightness a little.
On a light section
Swap the background class and pick a dark colour.
In a brand colour
Any CSS colour works for the dots and lines, including a theme variable.
Signal acquired
Props
childrenContent shown over the grid. It fills the grid, so lay it out yourself, for example with flex centring.
TypeReact.ReactNodeclassNameClasses for the wrapper. The grid fills it, so give it a height. Its background shows through the grid.
TypestringcolorColour of the dots and lines, as any CSS colour, including a theme variable. Pick the colour you would use for text on this background.
TypestringDefault"currentColor"brightnessMultiplies the opacity of dots, lines and glow. Values from 0.5 to 2 work well.
TypenumberDefault1.0reducedMotion"user" follows a surrounding MotionConfig, then the visitor's reduce-motion setting. "always" and "never" force the calm or the full version.
Type"user""always""never"Default"user"
Also takes every <div> prop except color.
Reduced motion
Repelling Grid follows the visitor's “reduce motion” device setting on its own: movement, blur and looping effects stop, and fades stay. Use the Reduced motion button on the preview to see that version. To decide yourself, set the reducedMotion prop on one instance, or wrap a whole section or app in Motion's MotionConfig.