Flickering Grid
A canvas-based component that creates a dynamic flickering grid background. Squares randomly change opacity to create a subtle, animated matrix-like effect.Installation
Usage
Props
The size of each square in pixels.
The gap between squares in pixels.
The probability that a square will change opacity each frame (0-1). Higher values create more rapid flickering.
The color of the squares. Accepts any valid CSS color value (rgb, hex, hsl, named colors).
Optional fixed width in pixels. If not provided, the component fills its container.
Optional fixed height in pixels. If not provided, the component fills its container.
The maximum opacity for squares (0-1).
Additional CSS classes to apply to the container element.
Examples
Basic Flickering Grid
Dark Theme with Blue Tint
Faster Flicker Rate
Larger Squares
Custom Color with High Contrast
Notes
- Uses HTML5 Canvas for high-performance rendering
- Animation pauses when component is not in viewport (uses Intersection Observer)
- Automatically handles device pixel ratio for crisp rendering
- Responsive to container size changes (uses ResizeObserver)
- Each square has random opacity assigned when flickering occurs
- Color conversion happens automatically for any CSS color format