BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/magicui/flickering-grid

Flickering Grid

magicui/flickering-grid
FreeComponent

A flickering grid background made with SVGs, fully customizable using Tailwind CSS.

Live preview

live · rendered by the registry
Rendered by magicui on their own page — this is the component running, not a screenshot of it.

Install it

npx shadcn@latest add https://magicui.design/r/flickering-grid.json

Source

registry/magicui/flickering-grid.tsxmagicui.design/r/flickering-grid.json
1"use client"
2
3import React, { useCallback, useEffect, useMemo, useRef, useState } from "react"
4
5import { cn } from "@/lib/utils"
6
7interface FlickeringGridProps extends React.HTMLAttributes<HTMLDivElement> {
8 squareSize?: number
9 gridGap?: number
10 flickerChance?: number
11 color?: string
12 width?: number
13 height?: number
14 className?: string
15 maxOpacity?: number
16}
17
18export const FlickeringGrid: React.FC<FlickeringGridProps> = ({
19 squareSize = 4,
20 gridGap = 6,
21 flickerChance = 0.3,
22 color = "rgb(0, 0, 0)",
23 width,
24 height,
25 className,
26 maxOpacity = 0.3,
27 ...props
28}) => {
29 const canvasRef = useRef<HTMLCanvasElement>(null)
30 const containerRef = useRef<HTMLDivElement>(null)
31 const [isInView, setIsInView] = useState(false)
32 const [canvasSize, setCanvasSize] = useState({ width: 0, height: 0 })
33
34 const memoizedColor = useMemo(() => {
35 const toRGBA = (color: string) => {
36 if (typeof window === "undefined") {
37 return `rgba(0, 0, 0,`
38 }
39 const canvas = document.createElement("canvas")
40 canvas.width = canvas.height = 1
41 const ctx = canvas.getContext("2d")
42 if (!ctx) return "rgba(255, 0, 0,"
43 ctx.fillStyle = color
44 ctx.fillRect(0, 0, 1, 1)
45 const [r, g, b] = Array.from(ctx.getImageData(0, 0, 1, 1).data)
46 return `rgba(${r}, ${g}, ${b},`
47 }
48 return toRGBA(color)
49 }, [color])
50
51 const setupCanvas = useCallback(
52 (canvas: HTMLCanvasElement, width: number, height: number) => {
53 const dpr = window.devicePixelRatio || 1
54 canvas.width = width * dpr
55 canvas.height = height * dpr
56 canvas.style.width = `${width}px`
57 canvas.style.height = `${height}px`
58 const cols = Math.ceil(width / (squareSize + gridGap))
59 const rows = Math.ceil(height / (squareSize + gridGap))
60
61 const squares = new Float32Array(cols * rows)
62 for (let i = 0; i < squares.length; i++) {
63 squares[i] = Math.random() * maxOpacity
64 }
65
66 return { cols, rows, squares, dpr }
67 },
68 [squareSize, gridGap, maxOpacity]
69 )
70
71 const updateSquares = useCallback(
72 (squares: Float32Array, deltaTime: number) => {
73 for (let i = 0; i < squares.length; i++) {
74 if (Math.random() < flickerChance * deltaTime) {
75 squares[i] = Math.random() * maxOpacity
76 }
77 }
78 },
79 [flickerChance, maxOpacity]
80 )
81
82 const drawGrid = useCallback(
83 (
84 ctx: CanvasRenderingContext2D,
85 width: number,
86 height: number,
87 cols: number,
88// … truncated

Files it writes

  • registry/magicui/flickering-grid.tsx

Facts

Registry
magicui
Type
registry:ui
Access
Free
Files written
1
Licence
the repository states none
First indexed
2026-08-02
Last confirmed
yesterday

Go to the source

Docs on magicui magicui.design magicuidesign/magicui on GitHub Raw registry item This item as JSON

More from magicui

All 247 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
AndroidandroidmagicuiComponentsFreeno deps
Animated Beamanimated-beammagicuiComponentsFree1 dep
Animated Circular Progress Baranimated-circular-progress-barmagicuiComponentsFreeno deps
Animated Gradient Textanimated-gradient-textmagicuiComponentsFreeno deps
Animated Grid Patternanimated-grid-patternmagicuiComponentsFree1 dep
Animated Listanimated-listmagicuiComponentsFree1 dep
Animated Shiny Textanimated-shiny-textmagicuiComponentsFreeno deps
Theme Toggleranimated-theme-togglermagicuiComponentsFree1 dep
BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex

BlockDex

Built by

Kynth Studio

Index

Components
Registries
Method
Open API

Guides

shadcn component libraries
Best shadcn registries
Free shadcn blocks

Reference

Corpus counts
Crawl health
hello@kynth.studio
Privacy
Terms

BlockDex