Background
Squares
Interactive animated grid patterns with hover effects and directional movement. Perfect for React applications requiring geometric backgrounds with Next.js integration and TypeScript support.
Powered by
Installation
npx shadcn@latest add https://www.shadcn.io/registry/squares-background.json
npx shadcn@latest add https://www.shadcn.io/registry/squares-background.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/squares-background.json
bunx shadcn@latest add https://www.shadcn.io/registry/squares-background.json
Features
- Multi-directional animation with smooth scrolling in right, left, up, down, or diagonal directions
- Interactive hover effects highlighting squares on mouse movement with customizable fill colors
- Adjustable speed control from subtle slow motion to dynamic fast animations
- Customizable grid styling configuring square size, border colors, and hover effects
- Canvas-based rendering using efficient HTML5 Canvas with requestAnimationFrame optimization
- Responsive adaptation automatically adjusting to container dimensions and window resize
- Touch-friendly interaction supporting both desktop mouse and mobile touch events
- TypeScript support with complete interface definitions for reliable integration
Examples
Moving Grid
Use Cases
This free open source React component works well for:
- Hero section backgrounds - Geometric patterns for modern landing pages built with Next.js
- Loading screens - Animated grids providing visual interest during data processing using TypeScript
- Portfolio overlays - Subtle background animations for creative showcases
- Dashboard interfaces - Professional grid patterns for admin panels using shadcn/ui design
- Interactive galleries - Hover-responsive backgrounds for image and content displays
- Brand experiences - Unique geometric animations expressing technical precision using Tailwind CSS
API Reference
Props
Prop | Type | Default | Description |
---|---|---|---|
direction | "right" | "left" | "up" | "down" | "diagonal" | "right" | Direction of grid movement |
speed | number | 1 | Animation speed (higher = faster) |
borderColor | string | "#333" | Color of the grid lines |
squareSize | number | 40 | Size of each square in pixels |
hoverFillColor | string | "#222" | Fill color when hovering over squares |
className | string | - | Additional CSS classes for the canvas |
Implementation Notes
- Component uses HTML5 Canvas API with requestAnimationFrame for smooth 60fps animation
- Grid automatically adapts to container dimensions and handles window resize events
- Hover detection optimized for responsiveness across desktop mouse and mobile touch
- Direction control supports five movement patterns: right, left, up, down, and diagonal
- Speed parameter ranges from 0 (static) to 2+ (fast) for different animation intensities
- Square size configurable from 20px (fine grid) to 80px+ (large grid) for visual density control
- Color customization supports RGBA values for theme integration and opacity control
- Compatible with shadcn/ui design system and Tailwind CSS utility classes for styling
Spiral Animation
Mesmerizing spiral animations with GSAP-powered smooth motion. Perfect for React applications requiring hypnotic visual effects with Next.js integration and TypeScript support.
Vortex
Mesmerizing particle vortex effects with simplex noise algorithms. Perfect for React applications requiring dynamic swirling animations with Next.js integration and TypeScript support.