Eye Tracking
componentry/eye-trackingFreeComponent
Component for eye-tracking
Live preview
live · rendered by the registry
Rendered by componentry on their own page — this is the component running, not a screenshot of it.Install it
npx shadcn@latest add https://componentry.dev/r/eye-tracking.jsonSource
1"use client"23import * as React from "react"4import { motion, useMotionValue, useSpring, useTransform } from "framer-motion"5import { cn } from "@/lib/utils"67interface EyeTrackingProps {8 /** Additional CSS classes */9 className?: string10 /** Size of each eye in pixels */11 eyeSize?: number12 /** Gap between eyes in pixels */13 gap?: number14 /** Color of the iris */15 irisColor?: string16 /** Secondary iris color for gradient */17 irisColorSecondary?: string18 /** Pupil color */19 pupilColor?: string20 /** Sclera (white) color */21 scleraColor?: string22 /** How far the pupil can travel (0-1) */23 pupilRange?: number24 /** Enable the reflection/glint effect */25 showReflection?: boolean26 /** Enable iris detail pattern */27 showIrisDetail?: boolean28 /** Enable subtle idle animation when cursor is away */29 idleAnimation?: boolean30 /** Blink interval in milliseconds (0 to disable) */31 blinkInterval?: number32 /** Number of eyes */33 eyeCount?: number34 /** Variant style */35 variant?: "realistic" | "cartoon" | "minimal" | "cyber"36 /** Enable reactive pupil dilation */37 reactivePupil?: boolean38 /** Eyelid visibility */39 showEyelids?: boolean40}4142interface EyeProps {43 eyeSize: number44 irisColor: string45 irisColorSecondary: string46 pupilColor: string47 scleraColor: string48 pupilRange: number49 showReflection: boolean50 showIrisDetail: boolean51 blinkInterval: number52 variant: "realistic" | "cartoon" | "minimal" | "cyber"53 reactivePupil: boolean54 showEyelids: boolean55 mouseX: React.MutableRefObject<number>56 mouseY: React.MutableRefObject<number>57 index: number58}5960function Eye({61 eyeSize,62 irisColor,63 irisColorSecondary,64 pupilColor,65 scleraColor,66 pupilRange,67 showReflection,68 showIrisDetail,69 blinkInterval,70 variant,71 reactivePupil,72 showEyelids,73 mouseX,74 mouseY,75 index,76}: EyeProps) {77 const eyeRef = React.useRef<HTMLDivElement>(null)78 const [isBlinking, setIsBlinking] = React.useState(false)79 const [pupilScale, setPupilScale] = React.useState(1)8081 const x = useMotionValue(0)82 const y = useMotionValue(0)83 const springX = useSpring(x, { stiffness: 300, damping: 25, mass: 0.5 })84 const springY = useSpring(y, { stiffness: 300, damping: 25, mass: 0.5 })8586 const irisSize = eyeSize * 0.4587 const pupilSize = irisSize * 0.588 const maxOffset = (eyeSize / 2 - irisSize / 2) * pupilRange8990 // Blink animation91 React.useEffect(() => {92 if (blinkInterval <= 0) return9394 const blink = () => {95 setIsBlinking(true)96// … truncated
More from componentry
All 59 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Animated Gradientanimated-gradient | componentry | Components | Free | no deps | |
| ASCII Effectascii-effect | componentry | Components | Free | no deps | |
| Aurora Flowaurora-flow | componentry | Components | Free | no deps | |
| auth-modalauth-modal | componentry | Components | Free | no deps | |
| border-beamborder-beam | componentry | Components | Free | no deps | |
| circuit-boardcircuit-board | componentry | Components | Free | no deps | |
| closing-plasmaclosing-plasma | componentry | Components | Free | no deps | |
| collection-surfercollection-surfer | componentry | Components | Free | no deps |
