Skip to content
synccn

Interactive Grid

New

Background grid whose squares light up under the pointer and fade behind it. Canvas-drawn, paused off screen.

Move your pointer

Squares light up and fade behind you. Set the colour with a text class.

Installation

$ pnpm dlx shadcn@latest add @synccn/interactive-grid

First time in this project? Connect synccn with one command.

Usage

import { InteractiveGrid } from "@/components/ui/interactive-grid";<InteractiveGrid className="h-72 text-primary">…</InteractiveGrid>

API reference

Generated from the component's TypeScript types, so it always matches the code.

InteractiveGrid

Background grid whose squares light up under the pointer and fade out behind it. Drawn on a canvas, paused when off screen, and static for people who prefer reduced motion.

  • cellSize
    number

    Default 32

    Size of each square, in pixels.

  • radius
    number

    Default 1

    How many cells around the pointer light up.

  • fade
    number

    Default 900

    How long a lit cell takes to fade, in milliseconds.

  • ambient
    boolean

    Default true

    Lights random cells now and then, so the grid looks alive on touch screens too.

  • className
    string

    Extra classes for the root element. The grid uses the text colour, so set it with a text-* class.

  • children
    React.ReactNode

    Content shown over the grid.

Dependencies

Read from the component's imports when the site builds. The CLI installs all of these for you.

Helpers

npm packages

Accessibility

  • The canvas is hidden from assistive tech. With reduced motion the grid is drawn once and doesn't react.

From the source

Read from this component's code when the site builds, so it can't drift.

  • Respects the reduced motion setting