BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/magicui/icon-cloud

Icon Cloud

magicui/icon-cloud
FreeComponent

An interactive 3D tag cloud component

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/icon-cloud.json

Source

registry/magicui/icon-cloud.tsxmagicui.design/r/icon-cloud.json · first 6 KB
1"use client"
2
3import React, { useEffect, useRef, useState } from "react"
4import { Pause, Play } from "lucide-react"
5import { renderToString } from "react-dom/server"
6
7import { Button } from "@/components/ui/button"
8
9interface Icon {
10 x: number
11 y: number
12 z: number
13 scale: number
14 opacity: number
15 id: number
16}
17
18interface IconCloudProps {
19 icons?: React.ReactNode[]
20 images?: string[]
21 showControl?: boolean
22}
23
24function easeOutCubic(t: number): number {
25 return 1 - Math.pow(1 - t, 3)
26}
27
28export function IconCloud({
29 icons,
30 images,
31 showControl = true,
32}: IconCloudProps) {
33 const canvasRef = useRef<HTMLCanvasElement>(null)
34 const [iconPositions, setIconPositions] = useState<Icon[]>([])
35 const [isDragging, setIsDragging] = useState(false)
36 const [isPaused, setIsPaused] = useState(false)
37 const [lastMousePos, setLastMousePos] = useState({ x: 0, y: 0 })
38 const [mousePos, setMousePos] = useState({ x: 0, y: 0 })
39 const [targetRotation, setTargetRotation] = useState<{
40 x: number
41 y: number
42 startX: number
43 startY: number
44 distance: number
45 startTime: number
46 duration: number
47 } | null>(null)
48 const animationFrameRef = useRef<number>(0)
49 const rotationRef = useRef({ x: 0, y: 0 })
50 const iconCanvasesRef = useRef<HTMLCanvasElement[]>([])
51 const imagesLoadedRef = useRef<boolean[]>([])
52
53 // Pause animation if user prefers reduced motion
54 useEffect(() => {
55 const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)")
56 if (mediaQuery.matches) {
57 setIsPaused(true)
58 }
59
60 const handleChange = (e: MediaQueryListEvent) => {
61 setIsPaused(e.matches)
62 }
63
64 mediaQuery.addEventListener("change", handleChange)
65 return () => mediaQuery.removeEventListener("change", handleChange)
66 }, [])
67
68 // Create icon canvases once when icons/images change
69 useEffect(() => {
70 if (!icons && !images) return
71
72 const items = icons ?? images ?? []
73 imagesLoadedRef.current = new Array(items.length).fill(false)
74
75 const newIconCanvases = items.map((item, index) => {
76 const offscreen = document.createElement("canvas")
77 offscreen.width = 40
78 offscreen.height = 40
79 const offCtx = offscreen.getContext("2d")
80
81 if (offCtx) {
82 if (images) {
83 // Handle image URLs directly
84 const img = new Image()
85 img.crossOrigin = "anonymous"
86 img.src = items[index] as string
87 img.onload = () => {
88// … truncated

What it pulls in

npm packages

  • lucide-react

Other registry items

  • button

Files it writes

  • registry/magicui/icon-cloud.tsx

Facts

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

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