BlockDex

Components

Registries

Free blocks

Method

BlockDex

Components

Registries

Free blocks

Method

Open API

BlockDex

Components

Registries

Free blocks

Method

Open API

Components/fancy/pixel-trail

Pixel Trail

fancy/pixel-trail
FreeComponent

A ui component.

Install it

npx shadcn@latest add https://www.fancycomponents.dev/r/pixel-trail.json

Source

fancy/background/pixel-trail.tsxwww.fancycomponents.dev/r/pixel-trail.json
1"use client"
2
3import React, { useCallback, useMemo, useRef } from "react"
4import { motion, useAnimationControls } from "motion/react"
5import { v4 as uuidv4 } from "uuid"
6
7import { cn } from "@/lib/utils"
8import { useDimensions } from "@/hooks/use-dimensions"
9
10interface PixelTrailProps {
11 pixelSize: number // px
12 fadeDuration?: number // ms
13 delay?: number // ms
14 className?: string
15 pixelClassName?: string
16}
17
18const PixelTrail: React.FC<PixelTrailProps> = ({
19 pixelSize = 20,
20 fadeDuration = 500,
21 delay = 0,
22 className,
23 pixelClassName,
24}) => {
25 const containerRef = useRef<HTMLDivElement>(null)
26 const dimensions = useDimensions(containerRef)
27 const trailId = useRef(uuidv4())
28
29 const handleMouseMove = useCallback(
30 (e: React.MouseEvent<HTMLDivElement>) => {
31 if (!containerRef.current) return
32
33 const rect = containerRef.current.getBoundingClientRect()
34 const x = Math.floor((e.clientX - rect.left) / pixelSize)
35 const y = Math.floor((e.clientY - rect.top) / pixelSize)
36
37 const pixelElement = document.getElementById(
38 `${trailId.current}-pixel-${x}-${y}`
39 )
40 if (pixelElement) {
41 const animatePixel = (pixelElement as any).__animatePixel
42 if (animatePixel) animatePixel()
43 }
44 },
45 [pixelSize]
46 )
47
48 const columns = useMemo(
49 () => Math.ceil(dimensions.width / pixelSize),
50 [dimensions.width, pixelSize]
51 )
52 const rows = useMemo(
53 () => Math.ceil(dimensions.height / pixelSize),
54 [dimensions.height, pixelSize]
55 )
56
57 return (
58 <div
59 ref={containerRef}
60 className={cn(
61 "absolute inset-0 w-full h-full pointer-events-auto",
62 className
63 )}
64 onMouseMove={handleMouseMove}
65 >
66 {Array.from({ length: rows }).map((_, rowIndex) => (
67 <div key={rowIndex} className="flex">
68 {Array.from({ length: columns }).map((_, colIndex) => (
69 <PixelDot
70 key={`${colIndex}-${rowIndex}`}
71 id={`${trailId.current}-pixel-${colIndex}-${rowIndex}`}
72 size={pixelSize}
73 fadeDuration={fadeDuration}
74 delay={delay}
75 className={pixelClassName}
76 />
77 ))}
78 </div>
79 ))}
80 </div>
81 )
82}
83
84export default PixelTrail
85
86interface PixelDotProps {
87 id: string
88 size: number
89 fadeDuration: number
90 delay: number
91 className?: string
92}
93
94const PixelDot: React.FC<PixelDotProps> = React.memo(
95 ({ id, size, fadeDuration, delay, className }) => {
96// … truncated

What it pulls in

npm packages

  • motion
  • uuid

Other registry items

  • hooks/use-dimensions

Files it writes

  • fancy/background/pixel-trail

Facts

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

Go to the source

www.fancycomponents.dev danielpetho/fancy on GitHub Raw registry item This item as JSON

More from fancy

All 158 items
Same registry, same kind — the ones you would have found next
ComponentRegistryKindAccessInstallsCommand
Animated Gradient With Svganimated-gradient-with-svgfancyComponentsFreeno deps
Basic Number Tickerbasic-number-tickerfancyComponentsFree1 dep
Box Carouselbox-carouselfancyComponentsFree1 dep
Breathing Textbreathing-textfancyComponentsFree1 dep
Circling Elementscircling-elementsfancyComponentsFree1 dep
Css Boxcss-boxfancyComponentsFree1 dep
Cursor Attractor And Gravitycursor-attractor-and-gravityfancyComponentsFree5 deps
Drag Elementsdrag-elementsfancyComponentsFree1 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