Background
Flickering Grid
Canvas-based flickering grid animations with performance optimization. Perfect for React applications requiring subtle animated backgrounds with Next.js integration and TypeScript support.
Powered by
Installation
npx shadcn@latest add https://www.shadcn.io/registry/flickering-grid.json
npx shadcn@latest add https://www.shadcn.io/registry/flickering-grid.json
pnpm dlx shadcn@latest add https://www.shadcn.io/registry/flickering-grid.json
bunx shadcn@latest add https://www.shadcn.io/registry/flickering-grid.json
Features
- Canvas-based animation with randomized square opacity changes creating dynamic flickering effects
- Performance optimized using Intersection Observer to pause animations when not visible
- High DPI support automatically adapting to device pixel ratio for crisp rendering
- Customizable grid parameters including square size, gap spacing, and overall dimensions
- Flexible color system supporting any CSS color format with automatic RGBA conversion
- Responsive design adapting to container size changes using ResizeObserver
- Memory efficient implementation using Float32Array for optimal performance
- TypeScript support with complete interface definitions for reliable integration
Examples
Blue Variant
Use Cases
This free open source React component works well for:
- Dashboard backgrounds - Subtle animated patterns for data-heavy interfaces built with Next.js
- Landing page sections - Dynamic grid effects that don't compete with content using TypeScript
- Portfolio layouts - Sophisticated animated backgrounds showcasing technical skills
- App interfaces - Ambient grid patterns for modern applications using shadcn/ui design
- Documentation sites - Technical precision patterns for developer resources
- Presentation backgrounds - Professional animated effects for slides using Tailwind CSS
API Reference
Props
Prop | Type | Default | Description |
---|---|---|---|
squareSize | number | 4 | Size of each square in pixels |
gridGap | number | 6 | Gap between squares in pixels |
flickerChance | number | 0.3 | Probability of a square flickering per second (0-1) |
color | string | "rgb(0, 0, 0)" | Color of the squares (any valid CSS color) |
width | number | - | Fixed width (uses container width if not specified) |
height | number | - | Fixed height (uses container height if not specified) |
className | string | - | Additional CSS classes for the container |
maxOpacity | number | 0.3 | Maximum opacity for squares (0-1) |
Implementation Notes
- Component uses HTML5 Canvas API for high-performance square rendering and animation
- Animation automatically pauses when not visible using Intersection Observer for battery efficiency
- Uses
requestAnimationFrame
for smooth 60fps animation with automatic container resizing - Color formats supported: RGB, hex, HSL, and named CSS colors with automatic RGBA conversion
- Grid density controlled by
squareSize
(2-8px) andgridGap
(3-12px) parameters - Flicker intensity adjustable via
flickerChance
(0-1) andmaxOpacity
(0-1) settings - Memory efficient implementation using Float32Array for optimal performance on large grids
- Compatible with shadcn/ui design system and responsive to container dimension changes
- Pointer events disabled to avoid interference with overlaid content and interactions
Fireworks Background
Interactive canvas-based fireworks animation with customizable particles and click-to-launch functionality. Perfect for React applications requiring celebratory backgrounds with Next.js integration and TypeScript support.
Grid Pattern
SVG-based grid patterns with masking and highlight effects. Perfect for React applications requiring structured backgrounds with Next.js integration and TypeScript support.