Back to PrequelUIYou are on Motion Grid.

Motion Grid

A dot grid that plays frame-by-frame motion as a loader or state.

Available inAvailable in React, Vue, Svelte, Solid, JavaScript· All five frameworks
PrequelUI

Libraries

PrequelUI

Motion

Spring + short tween

Reduced motion

Fade in place
motion-grid.tsx
Play with the real component, then read the code it ships with.All components
01

Installation

Installing for React·components/prequelui/motion-grid.tsx

Add the component

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/motion-grid.json
npmthe default on every machine

First component? Set up your project first

Frameworks

The live preview is React. Each tab below is the file that ships for that framework, with the same durations, springs and reduced-motion rule.

5 runtimes
motion-grid.tsx
"use client";

import * as React from "react";
import { motion, useInView } from "motion/react";
import { cn } from "@/lib/utils";
import { useReduceMotion } from "./motion";

export type MotionGridProps = Omit<React.ComponentProps<"div">, "onChange"> & {
  count?: number;
  columns?: number;
  dotSize?: number;
  gap?: number;
  speed?: number;
  stagger?: number;
  pauseOnHover?: boolean;
  dotClassName?: string;
};

export function MotionGrid({
  count = 35,
  columns = 7,
  dotSize = 8,
  gap = 10,
  speed = 1.4,
  stagger = 0.07,
  pauseOnHover = true,
  dotClassName,
  className,
  onPointerEnter,
  onPointerLeave,
  style,
  ...props
}: MotionGridProps) {
  const reduce = useReduceMotion();
  const ref = React.useRef<HTMLDivElement>(null);
  const inView = useInView(ref, { margin: "120px 0px" });
  const [paused, setPaused] = React.useState(false);
  const total = Math.max(1, Math.round(count));
  const cols = Math.max(1, Math.round(columns));

  return (
    <div
      ref={ref}
      data-slot="motion-grid"
      aria-hidden="true"
      className={cn("grid w-fit", className)}
      style={{
        gridTemplateColumns: `repeat(${cols}, minmax(0, 1fr))`,
        gap,
        ...style,
      }}
      onPointerEnter={(event) => {
        onPointerEnter?.(event);
        if (pauseOnHover) setPaused(true);
      }}
      onPointerLeave={(event) => {
        onPointerLeave?.(event);
        if (pauseOnHover) setPaused(false);
      }}
      {...props}
    >
      {Array.from({ length: total }, (_, index) => {
        const row = Math.floor(index / cols);
        const column = index % cols;
        const delay = (row + column) * stagger;
        const resting = reduce || paused || !inView;
        return (
          <motion.span
            key={index}
            className={cn("rounded-full bg-foreground", dotClassName)}
            style={{ width: dotSize, height: dotSize }}
            animate={
              resting
                ? { scale: 1, opacity: paused ? 0.35 : 0.55 }
                : {
                    scale: [0.65, 1, 0.65],
                    opacity: [0.3, 1, 0.3],
                  }
            }
            transition={
              resting
                ? { duration: reduce ? 0 : 0.2 }
                : {
                    duration: speed,
                    repeat: Infinity,
                    delay,
                    ease: "easeInOut",
                  }
            }
          />
        );
      })}
    </div>
  );
}

Install

npx shadcn@latest add https://prequeluianimate.terravidhal.me/r/motion-grid.json
npmthe default on every machine

Dependencies

motion lucide-react

The registry keeps the component source, its motion tokens and the reduced-motion branch together, so the install never pulls a different animation from the preview.

02

Usage

Import the component and compose it exactly like the primitive it wraps. Motion is enabled by default; the tempo prop scales every duration and softens every spring.

motion-grid.tsx
import { MotionGrid } from "@/components/prequelui/motion-grid";

export default function Demo() {
  return <MotionGrid className="rounded-xl border p-5" />;
}
import { MotionGrid } from "@/components/prequelui/motion-grid";

export function Variant() {
  return (
    <MotionGrid tempo={1.2}>
      …
    </MotionGrid>
  );
}
03

Animation

A field of dots ripples in a diagonal wave. Each dot waits for its row and column before starting, so the eye reads a single travelling front instead of noise.

  • Wave: each dot repeats every 1.4 s with easeInOut.
  • Stagger: 70 ms per row plus column step.
  • Hover settles the whole field at 35% opacity.
  • Reduced motion holds a static, evenly lit grid.
spring 500 / 50pause off-screenpointer-awareinterruptible
04

API Reference

Each part accepts the usual HTML props in addition to the motion props below. No accessibility prop is hidden behind the animation layer.

MotionGrid

PropTypeDefault
countnumber35
columnsnumber7
dotSizenumber8
gapnumber10
speednumber1.4
staggernumber0.07
pauseOnHoverbooleantrue

Next component

Page Transition

Page changes revealed with the View Transitions API.